lens 4.0.7 → 4.1
raw patch · 7 files changed
+71/−15 lines, 7 filesdep +freedep −base-orphansdep ~base
Dependencies added: free
Dependencies removed: base-orphans
Dependency ranges changed: base
Files
- CHANGELOG.markdown +5/−0
- lens.cabal +2/−1
- src/Control/Lens/Internal/TupleIxedTH.hs +4/−0
- src/Control/Lens/Plated.hs +43/−13
- src/Control/Lens/TH.hs +8/−0
- src/Data/List/Lens.hs +1/−1
- src/Language/Haskell/TH/Lens.hs +8/−0
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+4.1+---+* Added `Plated` instances for various free monad variants.+* Compatibility with GHC HEAD (7.9+)+ 4.0.7 ----- * Removed dependency on `constraints`. It was used in a pre-release version of 4.0 but never made it into 4.0, but the dependency had remained around complicating builds for GHC 7.4.
lens.cabal view
@@ -1,6 +1,6 @@ name: lens category: Data, Lenses, Generics-version: 4.0.7+version: 4.1 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -192,6 +192,7 @@ containers >= 0.4.0 && < 0.6, distributive >= 0.3 && < 1, filepath >= 1.2.0.0 && < 1.4,+ free >= 4 && < 5, ghc-prim, hashable >= 1.1.2.3 && < 1.3, exceptions >= 0.1.1 && < 1,
src/Control/Lens/Internal/TupleIxedTH.hs view
@@ -63,7 +63,11 @@ tupleIxed n = instanceD (cxt eqs) (conT ixedN `appT` fullTupleT n) [funD ixN clauses] where ty0:tyN = take n tupleVarTypes+#if __GLASGOW_HASKELL__ >= 709+ eqs = [AppT . AppT EqualityT <$> ty0 <*> ty | ty <- tyN]+#else eqs = [ty0 `equalP` ty | ty <- tyN]+#endif clauses = map nClause [0..n-1] ++ [otherClause] -- ix i f (a,..) = fmap (\x->(a,..x..)) (f z)
src/Control/Lens/Plated.hs view
@@ -79,20 +79,27 @@ ) where -import Control.Applicative-import Control.Lens.Fold-import Control.Lens.Getter-import Control.Lens.Indexed-import Control.Lens.Internal.Context-import Control.Lens.Type-import Control.Lens.Setter-import Control.Lens.Traversal+import Control.Applicative+import Control.Comonad.Cofree+import Control.Lens.Fold+import Control.Lens.Getter+import Control.Lens.Indexed+import Control.Lens.Internal.Context+import Control.Lens.Type+import Control.Lens.Setter+import Control.Lens.Traversal+import Control.Monad.Free as Monad+import Control.Monad.Free.Church as Church+import Control.Monad.Trans.Free as Trans+-- import Control.Monad.Trans.Free.Church as ChurchT+import Control.MonadPlus.Free as MonadPlus import qualified Language.Haskell.TH as TH-import Data.Aeson-import Data.Data-import Data.Data.Lens-import Data.Monoid-import Data.Tree+import Data.Aeson+import Data.Bitraversable+import Data.Data+import Data.Data.Lens+import Data.Monoid+import Data.Tree #ifdef HLINT {-# ANN module "HLint: ignore Reduce duplication" #-}@@ -201,6 +208,29 @@ instance Plated [a] where plate f (x:xs) = (x:) <$> f xs plate _ [] = pure []++instance Traversable f => Plated (Monad.Free f a) where+ plate f (Monad.Free as) = Monad.Free <$> traverse f as+ plate _ x = pure x++instance (Traversable f, Traversable m) => Plated (Trans.FreeT f m a) where+ plate f (Trans.FreeT xs) = Trans.FreeT <$> traverse (bitraverse pure f) xs++instance Traversable f => Plated (MonadPlus.Free f a) where+ plate f (MonadPlus.Free as) = MonadPlus.Free <$> traverse f as+ plate f (MonadPlus.Plus as) = MonadPlus.Plus <$> traverse f as+ plate _ x = pure x++instance Traversable f => Plated (Church.F f a) where+ plate f = fmap Church.toF . plate (fmap Church.fromF . f . Church.toF) . Church.fromF++-- -- This one can't work+--+-- instance (Traversable f, Traversable m) => Plated (ChurchT.FT f m a) where+-- plate f = fmap ChurchT.toFT . plate (fmap ChurchT.fromFT . f . ChurchT.toFT) . ChurchT.fromFT++instance Traversable f => Plated (Cofree f a) where+ plate f (a :< as) = (:<) a <$> traverse f as instance Plated (Tree a) where plate f (Node a as) = Node a <$> traverse f as
src/Control/Lens/TH.hs view
@@ -1030,7 +1030,11 @@ ctx = dataContext dataDecl ps = filter relevantCtx (substTypeVars m ctx) qs = case maybeClassName of+#if __GLASGOW_HASKELL__ >= 709+ Just n | not (cfg^.createClass) -> AppT (ConT n) (VarT t) : (ctx ++ ps)+#else Just n | not (cfg^.createClass) -> ClassP n [VarT t] : (ctx ++ ps)+#endif | otherwise -> ps _ -> ctx ++ ps tvs' = case maybeClassName of@@ -1162,7 +1166,11 @@ appliedType' = return (fullType dataDecl (map VarT typeArgs')) -- Con a' b' c'... ~ t+#if __GLASGOW_HASKELL__ >= 709+ eq = AppT. AppT EqualityT <$> appliedType' <*> t+#else eq = equalP appliedType' t+#endif -- Rewrapped (Con a b c...) t klass = conT ''Rewrapped `appsT` [appliedType, t]
src/Data/List/Lens.hs view
@@ -49,7 +49,7 @@ {-# INLINE prefixed #-} -- | A 'Prism' stripping a suffix from a list when used as a 'Traversal', or--- prepending that prefix when run backwards:+-- appending that suffix when run backwards: -- -- >>> "review" ^? suffixed "view" -- Just "re"
src/Language/Haskell/TH/Lens.hs view
@@ -249,9 +249,11 @@ , _NumTyLit , _StrTyLit #endif+#if __GLASGOW_HASKELL__ < 709 -- ** Pred Prisms , _ClassP , _EqualP+#endif #if MIN_VERSION_template_haskell(2,9,0) -- ** Role Prisms , _NominalR@@ -322,9 +324,11 @@ where s' = s `Set.union` setOf typeVars bs typeVarsEx _ _ t = pure t +#if __GLASGOW_HASKELL__ < 709 instance HasTypeVars Pred where typeVarsEx s f (ClassP n ts) = ClassP n <$> typeVarsEx s f ts typeVarsEx s f (EqualP l r) = EqualP <$> typeVarsEx s f l <*> typeVarsEx s f r+#endif instance HasTypeVars Con where typeVarsEx s f (NormalC n ts) = NormalC n <$> traverseOf (traverse . _2) (typeVarsEx s f) ts@@ -361,9 +365,11 @@ instance SubstType t => SubstType [t] where substType = map . substType +#if __GLASGOW_HASKELL__ < 709 instance SubstType Pred where substType m (ClassP n ts) = ClassP n (substType m ts) substType m (EqualP l r) = substType m (EqualP l r)+#endif -- | Provides a 'Traversal' of the types of each field of a constructor. conFields :: Traversal' Con StrictType@@ -1753,6 +1759,7 @@ reviewer x = Left x #endif +#if __GLASGOW_HASKELL__ < 709 _ClassP :: Prism' Pred (Name, [Type]) _ClassP = prism remitter reviewer@@ -1768,6 +1775,7 @@ remitter (x, y) = EqualP x y reviewer (EqualP x y) = Right (x, y) reviewer x = Left x+#endif #if MIN_VERSION_template_haskell(2,9,0) _NominalR :: Prism' Role ()