microlens-th 0.4.3.4 → 0.4.3.5
raw patch · 4 files changed
+58/−22 lines, 4 filesdep ~template-haskellPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: template-haskell
API changes (from Hackage documentation)
+ Lens.Micro.TH.Internal: _ForallT :: Traversal' Type ([TyVarBndr], Cxt, Type)
+ Lens.Micro.TH.Internal: elemOf :: Eq a => Getting (Endo [a]) s a -> a -> s -> Bool
+ Lens.Micro.TH.Internal: lengthOf :: Getting (Endo [a]) s a -> s -> Int
+ Lens.Micro.TH.Internal: setOf :: Ord a => Getting (Endo [a]) s a -> s -> Set a
Files
- CHANGELOG.md +4/−0
- microlens-th.cabal +3/−2
- src/Lens/Micro/TH.hs +0/−16
- src/Lens/Micro/TH/Internal.hs +51/−4
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.4.3.5++* Changes needed for template-haskell-2.16.+ # 0.4.3.4 * Backported changes needed for template-haskell-2.15.
microlens-th.cabal view
@@ -1,5 +1,5 @@ name: microlens-th-version: 0.4.3.4+version: 0.4.3.5 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).@@ -25,6 +25,7 @@ GHC==8.4.4 GHC==8.6.5 GHC==8.8.1+ GHC==8.10.1 source-repository head type: git@@ -40,7 +41,7 @@ , containers >=0.4.0 && <0.7 , transformers -- lens has >=2.4, but GHC 7.4 shipped with 2.7- , template-haskell >=2.7 && <2.16+ , template-haskell >=2.7 && <2.17 , th-abstraction >=0.2.1 && <0.4 ghc-options:
src/Lens/Micro/TH.hs view
@@ -70,7 +70,6 @@ import Data.Either import qualified Data.Map as Map import Data.Map (Map)-import Data.Monoid import qualified Data.Set as Set import Data.Set (Set) import Data.List (nub, findIndices, stripPrefix, isPrefixOf)@@ -154,21 +153,6 @@ If you want to export true folds, it's recommended that you depend on <http://hackage.haskell.org/package/microlens-contra microlens-contra>, use 'makeLensesFor' to generate 'SimpleFold's with prefixes, and then export versions of those folds with @<http://hackage.haskell.org/package/microlens-contra/docs/Lens-Micro-Contra.html#v:fromSimpleFold fromSimpleFold>@ applied. -}---- Lens functions which would've been in Lens.Micro if it wasn't “micro”--elemOf :: Eq a => Getting (Endo [a]) s a -> a -> s -> Bool-elemOf l x s = elem x (s ^.. l)--lengthOf :: Getting (Endo [a]) s a -> s -> Int-lengthOf l s = length (s ^.. l)--setOf :: Ord a => Getting (Endo [a]) s a -> s -> Set a-setOf l s = Set.fromList (s ^.. l)--_ForallT :: Traversal' Type ([TyVarBndr], Cxt, Type)-_ForallT f (ForallT a b c) = (\(x, y, z) -> ForallT x y z) <$> f (a, b, c)-_ForallT _ other = pure other -- Utilities
src/Lens/Micro/TH/Internal.hs view
@@ -35,9 +35,16 @@ inlinePragma, conAppsT, quantifyType, quantifyType',++ -- * Lens functions+ elemOf,+ lengthOf,+ setOf,+ _ForallT, ) where +import Data.Monoid import qualified Data.Map as Map import Data.Map (Map) import qualified Data.Set as Set@@ -49,7 +56,6 @@ #if __GLASGOW_HASKELL__ < 710 import Control.Applicative-import Data.Monoid import Data.Traversable (traverse) #endif @@ -103,14 +109,31 @@ instance HasTypeVars Type where typeVarsEx s f (VarT n) = VarT <$> typeVarsEx s f n typeVarsEx s f (AppT l r) = AppT <$> typeVarsEx s f l <*> typeVarsEx s f r+ typeVarsEx s f (ForallT bs ctx ty) = ForallT bs <$> typeVarsEx s' f ctx <*> typeVarsEx s' f ty+ where s' = s `Set.union` setOf typeVars bs+ typeVarsEx _ _ t@ConT{} = pure t+ typeVarsEx _ _ t@TupleT{} = pure t+ typeVarsEx _ _ t@ListT{} = pure t+ typeVarsEx _ _ t@ArrowT{} = pure t+ typeVarsEx _ _ t@UnboxedTupleT{} = pure t #if MIN_VERSION_template_haskell(2,8,0) typeVarsEx s f (SigT t k) = SigT <$> typeVarsEx s f t <*> typeVarsEx s f k #else typeVarsEx s f (SigT t k) = (`SigT` k) <$> typeVarsEx s f t #endif- typeVarsEx s f (ForallT bs ctx ty) = ForallT bs <$> typeVarsEx s' f ctx <*> typeVarsEx s' f ty- where s' = s `Set.union` Set.fromList (bs ^.. typeVars)+#if MIN_VERSION_template_haskell(2,8,0)+ typeVarsEx _ _ t@PromotedT{} = pure t+ typeVarsEx _ _ t@PromotedTupleT{} = pure t+ typeVarsEx _ _ t@PromotedNilT{} = pure t+ typeVarsEx _ _ t@PromotedConsT{} = pure t+ typeVarsEx _ _ t@StarT{} = pure t+ typeVarsEx _ _ t@ConstraintT{} = pure t+ typeVarsEx _ _ t@LitT{} = pure t+#endif+#if MIN_VERSION_template_haskell(2,10,0)+ typeVarsEx _ _ t@EqualityT{} = pure t+#endif #if MIN_VERSION_template_haskell(2,11,0) typeVarsEx s f (InfixT t1 n t2) = InfixT <$> typeVarsEx s f t1 <*> pure n@@ -119,13 +142,20 @@ <*> pure n <*> typeVarsEx s f t2 typeVarsEx s f (ParensT t) = ParensT <$> typeVarsEx s f t+ typeVarsEx _ _ t@WildCardT{} = pure t #endif+#if MIN_VERSION_template_haskell(2,12,0)+ typeVarsEx _ _ t@UnboxedSumT{} = pure t+#endif #if MIN_VERSION_template_haskell(2,15,0) typeVarsEx s f (AppKindT t k) = AppKindT <$> typeVarsEx s f t <*> typeVarsEx s f k typeVarsEx s f (ImplicitParamT n t) = ImplicitParamT n <$> typeVarsEx s f t #endif- typeVarsEx _ _ t = pure t+#if MIN_VERSION_template_haskell(2,16,0)+ typeVarsEx s f (ForallVisT bs ty) = ForallVisT bs <$> typeVarsEx s' f ty+ where s' = s `Set.union` setOf typeVars bs+#endif #if !MIN_VERSION_template_haskell(2,10,0) instance HasTypeVars Pred where@@ -189,3 +219,20 @@ $ filter (`Set.notMember` exclude) $ nub -- stable order $ toListOf typeVars t++----------------------------------------------------------------------------+-- Lens functions which would've been in Lens.Micro if it wasn't “micro”+----------------------------------------------------------------------------++elemOf :: Eq a => Getting (Endo [a]) s a -> a -> s -> Bool+elemOf l x s = elem x (s ^.. l)++lengthOf :: Getting (Endo [a]) s a -> s -> Int+lengthOf l s = length (s ^.. l)++setOf :: Ord a => Getting (Endo [a]) s a -> s -> Set a+setOf l s = Set.fromList (s ^.. l)++_ForallT :: Traversal' Type ([TyVarBndr], Cxt, Type)+_ForallT f (ForallT a b c) = (\(x, y, z) -> ForallT x y z) <$> f (a, b, c)+_ForallT _ other = pure other