microlens-th 0.4.2 → 0.4.2.1
raw patch · 5 files changed
+44/−3 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−1
- microlens-th.cabal +2/−1
- src/Lens/Micro/TH.hs +12/−1
- test/T799.hs +24/−0
- test/templates.hs +1/−0
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.4.2.1++* Fixed [lens bug #799](https://github.com/ekmett/lens/issues/799) (`makeFields` instances violate coverage condition).+ # 0.4.2 * We now depend on `th-abstraction` (like `lens` itself).@@ -21,7 +25,7 @@ # 0.4.0.1 -* Ported a lens commit that (probably) makes lens generation deterministic. See [this issue](https://github.com/aelve/microlens/issues/83).+* Ported a lens commit that (probably) makes lens generation deterministic. See [issue #83](https://github.com/aelve/microlens/issues/83). # 0.4.0.0
microlens-th.cabal view
@@ -1,5 +1,5 @@ name: microlens-th-version: 0.4.2+version: 0.4.2.1 synopsis: Automatic generation of record lenses for microlens description: This package lets you automatically generate lenses for data types; code was extracted from the lens package, and therefore generated lenses are fully compatible with ones generated by lens (and can be used both from lens and microlens).@@ -52,6 +52,7 @@ test-suite templates type: exitcode-stdio-1.0 main-is: templates.hs+ other-modules: T799 ghc-options: -Wall -threaded hs-source-dirs: test
src/Lens/Micro/TH.hs view
@@ -1138,9 +1138,20 @@ containsTypeFamilies = go <=< D.resolveTypeSynonyms where- go (ConT nm) = (\i -> case i of FamilyI{} -> True; _ -> False)+ go (ConT nm) = (\i -> case i of FamilyI d _ -> isTypeFamily d; _ -> False) <$> reify nm go ty = or <$> traverse go (children ty)++#if MIN_VERSION_template_haskell(2,11,0)+ isTypeFamily OpenTypeFamilyD{} = True+ isTypeFamily ClosedTypeFamilyD{} = True+#elif MIN_VERSION_template_haskell(2,9,0)+ isTypeFamily (FamilyD TypeFam _ _ _) = True+ isTypeFamily ClosedTypeFamilyD{} = True+#else+ isTypeFamily (FamilyD TypeFam _ _ _) = True+#endif+ isTypeFamily _ = False pickInstanceDec hasFamilies | hasFamilies = do
+ test/T799.hs view
@@ -0,0 +1,24 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+-- | Test 'makeFields' on a field whose type has a data family. Unlike for+-- type families, for data families we do not generate type equality+-- constraints, as they are not needed to avoid the issue in #754.+--+-- This tests that the fix for #799 is valid by putting this in a module in+-- which UndecidableInstances is not enabled.+module T799 where++import Lens.Micro+import Lens.Micro.TH++data family DF a+newtype instance DF Int = FooInt Int++data Bar = Bar { _barFoo :: DF Int }+makeFields ''Bar++checkBarFoo :: Lens' Bar (DF Int)+checkBarFoo = foo
test/templates.hs view
@@ -26,6 +26,7 @@ import Lens.Micro import Lens.Micro.TH+import T799 () data Bar a b c = Bar { _baz :: (a, b) } makeLenses ''Bar