lens 4.12.1 → 4.12.2
raw patch · 15 files changed
+163/−6 lines, 15 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Control.Lens.Plated: instance (Traversable f, Traversable w) => Plated (CofreeT f w a)
- Control.Lens.Fold: foldByOf :: (forall i. Getting (M a i) s a) -> (a -> a -> a) -> a -> s -> a
+ Control.Lens.Fold: foldByOf :: (forall i. Reifies i (ReifiedMonoid a) => Getting (M a i) s a) -> (a -> a -> a) -> a -> s -> a
- Control.Lens.Fold: foldMapByOf :: (forall s. Getting (M r s) t a) -> (r -> r -> r) -> r -> (a -> r) -> t -> r
+ Control.Lens.Fold: foldMapByOf :: (forall i. Reifies i (ReifiedMonoid r) => Getting (M r i) s a) -> (r -> r -> r) -> r -> (a -> r) -> s -> r
Files
- CHANGELOG.markdown +5/−0
- lens.cabal +6/−2
- src/Control/Lens.hs +1/−0
- src/Control/Lens/Fold.hs +67/−2
- src/Control/Lens/Getter.hs +10/−0
- src/Control/Lens/Internal/Indexed.hs +9/−0
- src/Control/Lens/Internal/Setter.hs +9/−0
- src/Control/Lens/Iso.hs +8/−0
- src/Control/Lens/Lens.hs +8/−0
- src/Control/Lens/Level.hs +8/−0
- src/Control/Lens/Plated.hs +5/−2
- src/Control/Lens/Review.hs +8/−0
- src/Control/Lens/Setter.hs +8/−0
- src/Control/Lens/Zoom.hs +8/−0
- tests/doctests.hsc +3/−0
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+4.12.2+------+* Incorporated a bug fix for `foldByOf` and `foldMapByOf` to actually let them work on folds.+* Added a `Plated` instance for `CofreeT`+ 4.12.1 ------ * The `Simple` type alias is now poly-kinded. This lets you use `Simple Field1 s a` and the like in constraints.
lens.cabal view
@@ -1,6 +1,6 @@ name: lens category: Data, Lenses, Generics-version: 4.12.1+version: 4.12.2 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -207,7 +207,7 @@ text >= 0.11 && < 1.3, transformers >= 0.2 && < 0.5, transformers-compat >= 0.4 && < 1,- unordered-containers >= 0.2 && < 0.3,+ unordered-containers >= 0.2.4 && < 0.3, vector >= 0.9 && < 0.12, void >= 0.5 && < 1 @@ -382,6 +382,10 @@ main-is: doctests.hs ghc-options: -Wall -threaded hs-source-dirs: tests++ if flag(trustworthy) && impl(ghc>=7.2)+ other-extensions: Trustworthy+ cpp-options: -DTRUSTWORTHY=1 if !flag(test-doctests) buildable: False
src/Control/Lens.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Lens
src/Control/Lens/Fold.hs view
@@ -4,6 +4,14 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} +#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif+ {-# OPTIONS_GHC -fno-warn-orphans #-} ---------------------------------------------------------------------------- -- |@@ -160,6 +168,7 @@ import Data.Profunctor.Rep import Data.Profunctor.Sieve import Data.Profunctor.Unsafe+import Data.Reflection import Data.Traversable import Prelude hiding (foldr) @@ -2487,14 +2496,70 @@ -- Folds with Reified Monoid ------------------------------------------------------------------------------ +-- | Fold a value using its 'Foldable' instance using+-- explicitly provided 'Monoid' operations. This is like 'fold'+-- where the 'Monoid' instance can be manually specified.+--+-- @+-- 'foldBy' 'mappend' 'mempty' ≡ 'fold'+-- @+--+-- >>> foldBy (++) [] ["hello","world"]+-- "helloworld" foldBy :: Foldable t => (a -> a -> a) -> a -> t a -> a foldBy f z = reifyFold f z (foldMap M) -foldByOf :: (forall i. Getting (M a i) s a) -> (a -> a -> a) -> a -> s -> a+-- | Fold a value using a specified 'Fold' and 'Monoid' operations.+-- This is like 'foldBy' where the 'Foldable' instance can be+-- manually specified.+--+-- @+-- 'foldByOf' 'folded' ≡ 'foldBy'+-- @+--+-- @+-- 'foldByOf' :: 'Getter' s a -> (a -> a -> a) -> a -> s -> a+-- 'foldByOf' :: 'Fold' s a -> (a -> a -> a) -> a -> s -> a+-- 'foldByOf' :: 'Lens'' s a -> (a -> a -> a) -> a -> s -> a+-- 'foldByOf' :: 'Traversal'' s a -> (a -> a -> a) -> a -> s -> a+-- 'foldByOf' :: 'Iso'' s a -> (a -> a -> a) -> a -> s -> a+-- @+--+-- >>> foldByOf both (++) [] ("hello","world")+-- "helloworld"+foldByOf :: (forall i. Reifies i (ReifiedMonoid a) => Getting (M a i) s a) -> (a -> a -> a) -> a -> s -> a foldByOf l f z = reifyFold f z (foldMapOf l M) +-- | Fold a value using its 'Foldable' instance using+-- explicitly provided 'Monoid' operations. This is like 'foldMap'+-- where the 'Monoid' instance can be manually specified.+--+-- @+-- 'foldMapBy' 'mappend' 'mempty' ≡ 'foldMap'+-- @+--+-- >>> foldMapBy (+) 0 length ["hello","world"]+-- 10 foldMapBy :: Foldable t => (r -> r -> r) -> r -> (a -> r) -> t a -> r foldMapBy f z g = reifyFold f z (foldMap (M #. g)) -foldMapByOf :: (forall s. Getting (M r s) t a) -> (r -> r -> r) -> r -> (a -> r) -> t -> r+-- | Fold a value using a specified 'Fold' and 'Monoid' operations.+-- This is like 'foldMapBy' where the 'Foldable' instance can be+-- manually specified.+--+-- @+-- 'foldMapByOf' 'folded' ≡ 'foldMapBy'+-- @+--+-- @+-- 'foldMapByOf' :: 'Getter' s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r+-- 'foldMapByOf' :: 'Fold' s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r+-- 'foldMapByOf' :: 'Traversal'' s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r+-- 'foldMapByOf' :: 'Lens'' s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r+-- 'foldMapByOf' :: 'Iso'' s a -> (r -> r -> r) -> r -> (a -> r) -> s -> r+-- @+--+-- >>> foldMapByOf both (+) 0 length ("hello","world")+-- 10+foldMapByOf :: (forall i. Reifies i (ReifiedMonoid r) => Getting (M r i) s a) -> (r -> r -> r) -> r -> (a -> r) -> s -> r foldMapByOf l f z g = reifyFold f z (foldMapOf l (M #. g))
src/Control/Lens/Getter.hs view
@@ -2,6 +2,16 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-}+++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif+ #if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE NoPolyKinds #-} {-# LANGUAGE NoDataKinds #-}
src/Control/Lens/Internal/Indexed.hs view
@@ -5,6 +5,15 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE MultiParamTypeClasses #-}++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif+ ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Internal.Indexed
src/Control/Lens/Internal/Setter.hs view
@@ -1,4 +1,13 @@ {-# LANGUAGE CPP #-}++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif+ ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Internal.Setter
src/Control/Lens/Iso.hs view
@@ -6,6 +6,14 @@ #ifndef MIN_VERSION_bytestring #define MIN_VERSION_bytestring(x,y,z) 1 #endif++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Iso
src/Control/Lens/Lens.hs view
@@ -9,6 +9,14 @@ #ifndef MIN_VERSION_mtl #define MIN_VERSION_mtl(x,y,z) 1 #endif++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif ------------------------------------------------------------------------------- -- | -- Module : Control.Lens.Lens
src/Control/Lens/Level.hs view
@@ -1,6 +1,14 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE FlexibleContexts #-}++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Level
src/Control/Lens/Plated.hs view
@@ -98,6 +98,7 @@ import Control.Applicative import Control.Comonad.Cofree+import qualified Control.Comonad.Trans.Cofree as CoTrans import Control.Lens.Fold import Control.Lens.Getter import Control.Lens.Indexed@@ -112,7 +113,6 @@ import Control.MonadPlus.Free as MonadPlus #endif import qualified Language.Haskell.TH as TH-import Data.Bitraversable import Data.Data import Data.Data.Lens import Data.Monoid@@ -232,7 +232,7 @@ 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+ plate f (Trans.FreeT xs) = Trans.FreeT <$> traverse (traverse f) xs #if !(MIN_VERSION_free(4,6,0)) instance Traversable f => Plated (MonadPlus.Free f a) where@@ -248,6 +248,9 @@ -- -- 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, Traversable w) => Plated (CoTrans.CofreeT f w a) where+ plate f (CoTrans.CofreeT xs) = CoTrans.CofreeT <$> traverse (traverse f) xs instance Traversable f => Plated (Cofree f a) where plate f (a :< as) = (:<) a <$> traverse f as
src/Control/Lens/Review.hs view
@@ -1,5 +1,13 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-}++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif ------------------------------------------------------------------------------- -- | -- Module : Control.Lens.Review
src/Control/Lens/Setter.hs view
@@ -3,6 +3,14 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-}++#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Setter
src/Control/Lens/Zoom.hs view
@@ -10,6 +10,14 @@ #define MIN_VERSION_mtl(x,y,z) 1 #endif +#ifndef MIN_VERSION_profunctors+#define MIN_VERSION_profunctors(x,y,z) 1+#endif++#if __GLASGOW_HASKELL__ < 708 || !(MIN_VERSION_profunctors(4,4,0))+{-# LANGUAGE Trustworthy #-}+#endif+ ------------------------------------------------------------------------------- -- | -- Module : Control.Lens.Zoom
tests/doctests.hsc view
@@ -60,6 +60,9 @@ : "-optP-include" : "-optPdist/build/autogen/cabal_macros.h" : "-hide-all-packages"+#ifdef TRUSTWORTHY+ : "-DTRUSTWORTHY=1"+#endif : map ("-package="++) deps ++ sources getSources :: IO [FilePath]