lens 2.7.0.1 → 2.8
raw patch · 6 files changed
+51/−21 lines, 6 filesdep ~base
Dependency ranges changed: base
Files
- CHANGELOG.markdown +4/−0
- lens.cabal +3/−3
- src/Control/Lens.hs +1/−1
- src/Control/Lens/TH.hs +5/−2
- src/Control/Lens/WithIndex.hs +36/−13
- src/Data/Data/Lens.hs +2/−2
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+2.8+---+* Restored compatibility with GHC 7.2. This required a major version bump due to making some MPTC-based default signatures conditional.+ 2.7 --- * Generalized the signature of `Getting`, `Acting` and `IndexedGetting` to help out with the common user code scenario of needing to read
lens.cabal view
@@ -1,6 +1,6 @@ name: lens category: Data, Lenses-version: 2.7.0.1+version: 2.8 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -37,7 +37,7 @@ . The core of this hierarchy looks like: .- <<https://github.com/ekmett/lens/wiki/images/Hierarchy-2.7.png>>+ <<https://github.com/ekmett/lens/wiki/images/Hierarchy-2.8.png>> . You can compose any two elements of the hierarchy above using (.) from the Prelude, and you can use any element of the hierarchy as any type it links to above it.@@ -134,7 +134,7 @@ library build-depends:- base >= 4.3 && < 5,+ base >= 4.4 && < 5, bytestring >= 0.9.1.10 && < 0.11, comonad == 3.0.*, comonad-transformers == 3.0.*,
src/Control/Lens.hs view
@@ -41,7 +41,7 @@ -- -- <http://github.com/ekmett/lens/wiki> ----- <<http://github.com/ekmett/lens/wiki/images/Hierarchy-2.7.png>>+-- <<http://github.com/ekmett/lens/wiki/images/Hierarchy-2.8.png>> ---------------------------------------------------------------------------- module Control.Lens ( module Control.Lens.Type
src/Control/Lens/TH.hs view
@@ -56,7 +56,7 @@ import Data.Function (on) import Data.List as List import Data.Map as Map hiding (toList,map,filter)-import Data.Maybe (isNothing,isJust, catMaybes)+import Data.Maybe (isNothing,isJust,catMaybes,fromJust) import Data.Ord (comparing) import Data.Set as Set hiding (toList,map,filter) import Data.Set.Lens@@ -430,7 +430,10 @@ | List.null fields = appE (varE 'pure) recon | otherwise- = uInfixE (lamE fpats recon) (varE '(<$>)) $ List.foldl1 (\l r -> uInfixE l (varE '(<*>)) r) fvals+ = let step Nothing r = Just $ infixE (Just $ lamE fpats recon) (varE '(<$>)) (Just r)+ step (Just l) r = Just $ infixE (Just l) (varE '(<*>)) (Just r)+ in fromJust $ List.foldl step Nothing fvals+ -- = infixE (Just $ lamE fpats recon) (varE '(<$>)) $ Just $ List.foldl1 (\l r -> infixE (Just l) (varE '(<*>)) (Just r)) fvals clause [varP f, conP conName cpats] (normalB expr) [] makeFieldLenses :: LensRules
src/Control/Lens/WithIndex.hs view
@@ -1,8 +1,12 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-}-{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-}+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ > 706+{-# LANGUAGE DefaultSignatures #-}+#define MPTC_DEFAULTS+#endif ------------------------------------------------------------------------------- -- | -- Module : Control.Lens.WithIndex@@ -84,8 +88,10 @@ class Functor f => FunctorWithIndex i f | f -> i where -- | Map with access to the index. imap :: (i -> a -> b) -> f a -> f b+#ifdef MPTC_DEFAULTS default imap :: TraversableWithIndex i f => (i -> a -> b) -> f a -> f b imap = imapOf itraversed+#endif -- | The 'IndexedSetter' for a 'FunctorWithIndex'. --@@ -108,8 +114,11 @@ -- -- @'foldMap' ≡ 'ifoldMap' '.' 'const'@ ifoldMap :: Monoid m => (i -> a -> m) -> f a -> m+#ifdef MPTC_DEFAULTS default ifoldMap :: (TraversableWithIndex i f, Monoid m) => (i -> a -> m) -> f a -> m ifoldMap = ifoldMapOf itraversed+ {-# INLINE ifoldMap #-}+#endif -- | Right-associative fold of an indexed container with access to the index @i@. --@@ -315,9 +324,11 @@ class (FunctorWithIndex i t, FoldableWithIndex i t, Traversable t) => TraversableWithIndex i t | t -> i where -- | Traverse an indexed container. itraverse :: Applicative f => (i -> a -> f b) -> t a -> f (t b)+#ifdef MPTC_DEFAULTS default itraverse :: Applicative f => (Int -> a -> f b) -> t a -> f (t b) itraverse = withIndex (indexed traverse) {-# INLINE itraverse #-}+#endif -- | The 'IndexedTraversal' of a 'TraversableWithIndex' container. itraversed :: TraversableWithIndex i f => IndexedTraversal i (f a) (f b) a b@@ -390,29 +401,41 @@ ------------------------------------------------------------------------------- -- | The position in the list is available as the index.-instance FunctorWithIndex Int []-instance FoldableWithIndex Int []-instance TraversableWithIndex Int []+instance FunctorWithIndex Int [] where+ imap = imapOf itraversed+instance FoldableWithIndex Int [] where+ ifoldMap = ifoldMapOf itraversed+instance TraversableWithIndex Int [] where+ itraverse = withIndex (indexed traverse) -- | The position in the sequence is available as the index.-instance FunctorWithIndex Int Seq-instance FoldableWithIndex Int Seq-instance TraversableWithIndex Int Seq+instance FunctorWithIndex Int Seq where+ imap = imapOf itraversed+instance FoldableWithIndex Int Seq where+ ifoldMap = ifoldMapOf itraversed+instance TraversableWithIndex Int Seq where+ itraverse = withIndex (indexed traverse) -instance FunctorWithIndex Int IntMap-instance FoldableWithIndex Int IntMap+instance FunctorWithIndex Int IntMap where+ imap = imapOf itraversed+instance FoldableWithIndex Int IntMap where+ ifoldMap = ifoldMapOf itraversed instance TraversableWithIndex Int IntMap where itraverse f = sequenceA . IntMap.mapWithKey f {-# INLINE itraverse #-} -instance Ord k => FunctorWithIndex k (Map k)-instance Ord k => FoldableWithIndex k (Map k)+instance Ord k => FunctorWithIndex k (Map k) where+ imap = imapOf itraversed+instance Ord k => FoldableWithIndex k (Map k) where+ ifoldMap = ifoldMapOf itraversed instance Ord k => TraversableWithIndex k (Map k) where itraverse f = sequenceA . Map.mapWithKey f {-# INLINE itraverse #-} -instance (Eq k, Hashable k) => FunctorWithIndex k (HashMap k)-instance (Eq k, Hashable k) => FoldableWithIndex k (HashMap k)+instance (Eq k, Hashable k) => FunctorWithIndex k (HashMap k) where+ imap = imapOf itraversed+instance (Eq k, Hashable k) => FoldableWithIndex k (HashMap k) where+ ifoldMap = ifoldMapOf itraversed instance (Eq k, Hashable k) => TraversableWithIndex k (HashMap k) where itraverse = HashMap.traverseWithKey {-# INLINE itraverse #-}
src/Data/Data/Lens.hs view
@@ -146,7 +146,7 @@ tInteger = typeOf (undefined :: Integer ) insertHitMap :: DataBox -> HitMap -> HitMap-insertHitMap box hit = fixEq trans (populate box) <> hit where+insertHitMap box hit = fixEq trans (populate box) `mappend` hit where populate :: DataBox -> HitMap populate a = f a M.empty where f (DataBox k v) m@@ -157,7 +157,7 @@ trans :: HitMap -> HitMap trans m = M.map f m where- f x = x <> foldMap g x+ f x = x `mappend` foldMap g x g x = M.lookupDefault (hit ! x) x m fixEq :: Eq a => (a -> a) -> a -> a