packages feed

lens 3.0.4 → 3.0.5

raw patch · 8 files changed

+28/−9 lines, 8 files

Files

.gitignore view
@@ -4,3 +4,4 @@ TAGS tags wip+.DS_Store
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+3.0.5+-----+* Fixed a bug in `rights1` and `lefts1` in `Control.Lens.Zipper` which would cause them to loop forever when given a 0 offset.+ 3.0.4 ----- * Added `?~`, `<?~`, `?=` and `<?=` to `Control.Lens.Setter` for setting the target(s) of a Lens to `Just` a value. They are particularly useful when combined with `at`.
lens.cabal view
@@ -1,6 +1,6 @@ name:          lens category:      Data, Lenses-version:       3.0.4+version:       3.0.5 license:       BSD3 cabal-version: >= 1.8 license-file:  LICENSE
src/Control/Lens/Fold.hs view
@@ -171,6 +171,8 @@ {-# INLINE filtered #-}  -- | This allows you to traverse the elements of a 'Control.Lens.Traversal.Traversal' or 'Fold' in the opposite order.+-- This will demote an 'Control.Lens.IndexedTraversal.IndexedTraversal' or 'Control.Lens.IndexedFold.IndexedFold' to a regular 'Control.Lens.Traversal.Traversal' or 'Fold';+-- to preserve the indices, use 'Control.Lens.IndexedFold.ibackwards' instead. -- -- Note: 'backwards' should have no impact on a 'Getter' 'Setter', 'Lens' or 'Control.Lens.Iso.Iso'. --@@ -199,11 +201,15 @@ -- -- >>> toListOf (droppingWhile (<=3) folded) [1..6] -- [4,5,6]+--+-- >>> toListOf (droppingWhile (<=3) folded) [1,6,1]+ droppingWhile :: (Gettable f, Applicative f)               => (c -> Bool)               -> Getting (Endo (f a)) a a c c               -> LensLike f a a c c droppingWhile p l f = foldrOf l (\a r -> if p a then r else f a *> r) noEffect+-- droppingWhile p l f = fst . foldrOf l (\a r -> let s = f a *> snd r in if p a then (snd r, s) else (s, s)) (noEffect, noEffect) {-# INLINE droppingWhile #-}  --------------------------
src/Control/Lens/Indexed.hs view
@@ -76,7 +76,7 @@  -- | Composition of 'Indexed' functions ----- Mnemonically, the @<@ and @>@ points to the fact that we want to preserve the indices.+-- Mnemonically, the @\<@ and @\>@ points to the fact that we want to preserve the indices. (<.>) :: Indexed (i, j) k => Index i b c -> Index j a b -> k a c f <.> g = icompose (,) f g {-# INLINE (<.>) #-}
src/Control/Lens/IndexedFold.hs view
@@ -42,6 +42,7 @@    -- * Building Indexed Folds   , ifiltered+  , ibackwards   , itakingWhile   , idroppingWhile @@ -50,6 +51,7 @@   ) where  import Control.Applicative+import Control.Applicative.Backwards import Control.Lens.Indexed import Control.Lens.IndexedGetter import Control.Lens.Internal@@ -401,10 +403,16 @@ -- Converting to Folds ------------------------------------------------------------------------------- --- | Obtain an 'IndexedFold' by filtering a 'Control.Lens.IndexedLens.IndexedLens', 'IndexedGetter', 'IndexedFold' or 'Control.Lens.IndexedTraversal.IndexedTraversal'.+-- | Obtain an 'IndexedFold' by filtering an 'Control.Lens.IndexedLens.IndexedLens', 'IndexedGetter', 'IndexedFold' or 'Control.Lens.IndexedTraversal.IndexedTraversal'. ifiltered :: (Gettable f, Applicative f, Indexed i k) => (i -> c -> Bool) -> Index i (c -> f c) (a -> f b) -> k (c -> f c) (a -> f b) ifiltered p l = index $ \ f -> withIndex l $ \ i c -> if p i c then f i c else noEffect {-# INLINE ifiltered #-}++-- | Reverse the order of the elements of an 'IndexedFold' or 'Control.Lens.IndexedTraversal.IndexedTraversal'.+-- This has no effect on an 'Control.Lens.IndexedLens.IndexedLens', 'IndexedGetter', or 'Control.Lens.IndexedSetter.IndexedSetter'.+ibackwards :: Indexed i k => Index i (c -> (Backwards f) d) (a -> (Backwards f) b) -> k (c -> f d) (a -> f b)+ibackwards l = index $ \ f -> fmap forwards . withIndex l $ \ i -> Backwards . f i+{-# INLINE ibackwards #-}  -- | Obtain an 'IndexedFold' by taking elements from another 'IndexedFold', 'Control.Lens.IndexedLens.IndexedLens', 'IndexedGetter' or 'Control.Lens.IndexedTraversal.IndexedTraversal' while a predicate holds. itakingWhile :: (Gettable f, Applicative f, Indexed i k)
src/Control/Lens/Type.hs view
@@ -260,9 +260,9 @@ -- following more restricted type signatures: -- -- @--- ('%%=') :: 'MonadState' a m             => 'Control.Lens.Iso.Iso' a a c d       -> (c -> (e, d) -> m e--- ('%%=') :: 'MonadState' a m             => 'Lens' a a c d      -> (c -> (e, d) -> m e--- ('%%=') :: ('MonadState' a m, 'Monoid' e) => 'Control.Lens.Traversal.Traversal' a a c d -> (c -> (e, d) -> m e+-- ('%%=') :: 'MonadState' a m             => 'Control.Lens.Iso.Iso' a a c d       -> (c -> (e, d)) -> m e+-- ('%%=') :: 'MonadState' a m             => 'Lens' a a c d      -> (c -> (e, d)) -> m e+-- ('%%=') :: ('MonadState' a m, 'Monoid' e) => 'Control.Lens.Traversal.Traversal' a a c d -> (c -> (e, d)) -> m e -- @ (%%=) :: MonadState a m => LensLike ((,) e) a a c d -> (c -> (e, d)) -> m e #if MIN_VERSION_mtl(2,1,1)
src/Control/Lens/Zipper.hs view
@@ -190,7 +190,7 @@ -- Passing a negative @n@ will move to @-n@ entries the right, and will return the last entry if you run out of entries. lefts1 :: Int -> (h :> a) -> h :> a lefts1 n z-  | n <= 0 = rights1 (-n) z+  | n < 0 = rights1 (-n) z   | otherwise = go n z   where go 0 c = c         go k c = case left c of@@ -202,7 +202,7 @@ -- Passing a negative number will move to the left and will return the first entry if you run out of entries. rights1 :: Int -> (h :> a) -> h :> a rights1 n z-  | n <= 0 = lefts1 (-n) z+  | n < 0 = lefts1 (-n) z   | otherwise = go n z   where go 0 c = c         go k c = case right c of@@ -281,7 +281,7 @@ -- -- You can reason about this function as if the definition was: ----- @'fromWithin' l ≡ 'fromMaybe' '.' 'within' l@+-- @'fromWithin' l ≡ 'fromJust ' '.' 'within' l@ -- -- but it is lazier in such a way that if this invariant is violated, some code -- can still succeed if it is lazy enough in the use of the focused value.