microlens 0.4.7.0 → 0.4.8.0
raw patch · 4 files changed
+48/−2 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Lens.Micro: forOf :: LensLike f s t a b -> s -> (a -> f b) -> f t
+ Lens.Micro: forOf_ :: Functor f => Getting (Traversed r f) s a -> s -> (a -> f r) -> f ()
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Each (Data.List.NonEmpty.NonEmpty a) (Data.List.NonEmpty.NonEmpty b) a b
Files
- CHANGELOG.md +5/−0
- microlens.cabal +1/−1
- src/Lens/Micro.hs +31/−0
- src/Lens/Micro/Internal.hs +11/−1
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.4.8.0++* Added `forOf_` and `forOf`.+* Added an instance for `Each (NonEmpty a)` (available starting from GHC 8).+ # 0.4.7.0 * Fixed the [Haddock crash on GHC 8](https://github.com/aelve/microlens/issues/72) by removing default method implementations (`each = traverse` and `ix = ixAt`). If you had custom instances of `Ixed` or `Each` which relied on default methods, they'd stop working.
microlens.cabal view
@@ -1,5 +1,5 @@ name: microlens-version: 0.4.7.0+version: 0.4.8.0 synopsis: A tiny lens library with no dependencies. If you're writing an app, you probably want microlens-platform, not this. description: NOTE: If you're writing an app, you probably want <http://hackage.haskell.org/package/microlens-platform microlens-platform> – it has the most features. <http://hackage.haskell.org/package/microlens microlens> is intended more for library writers who want a tiny lens library (after all, lenses are pretty useful for everything, not just for updating records!).
src/Lens/Micro.hs view
@@ -58,6 +58,7 @@ (^?), (^?!), traverseOf_,+ forOf_, has, folded, folding,@@ -78,6 +79,7 @@ -- $traversals-note Traversal, Traversal', traverseOf,+ forOf, singular, failing, filtered,@@ -607,6 +609,27 @@ {-# INLINE traverseOf_ #-} {- |+'traverseOf_' with flipped arguments. Useful if the “loop body” is a lambda+or a @do@ block, or in some other cases – for instance, you can avoid+accidentally using 'Data.Foldable.for_' on a tuple or 'Either' by switching+to @'forOf_' 'each'@. Or you can write custom loops like these:++@+'forOf_' 'both' (a, b) $ \\x -\>+ ...+'forOf_' 'each' [1..10] $ \\x -\>+ ...+'forOf_' ('each' . '_Right') $ \\x -\>+ ...+@+-}+forOf_+ :: Functor f+ => Getting (Traversed r f) s a -> s -> (a -> f r) -> f ()+forOf_ = flip . traverseOf_+{-# INLINE forOf_ #-}++{- | 'has' checks whether a getter (any getter, including lenses, traversals, and folds) returns at least 1 value. Checking whether a list is non-empty:@@ -880,6 +903,14 @@ traverseOf :: LensLike f s t a b -> (a -> f b) -> s -> f t traverseOf = id {-# INLINE traverseOf #-}++{- |+'traverseOf' with flipped arguments. Useful if the “loop body” is a lambda or+a @do@ block.+-}+forOf :: LensLike f s t a b -> s -> (a -> f b) -> f t+forOf = flip+{-# INLINE forOf #-} {- | 'singular' turns a traversal into a lens that behaves like a single-element traversal:
src/Lens/Micro/Internal.hs view
@@ -64,6 +64,10 @@ import Data.Functor.Identity import Data.Complex +#if __GLASGOW_HASKELL__ >= 800+import Data.List.NonEmpty (NonEmpty)+#endif+ #if __GLASGOW_HASKELL__ < 710 import Data.Traversable #endif@@ -73,8 +77,8 @@ #else import Unsafe.Coerce #endif- + {- | 'traversed' traverses any 'Traversable' container (list, vector, @Map@, 'Maybe', you name it): @@ -217,6 +221,12 @@ instance Each (Maybe a) (Maybe b) a b where each = traverse {-# INLINE each #-}++#if __GLASGOW_HASKELL__ >= 800+instance Each (NonEmpty a) (NonEmpty b) a b where+ each = traversed+ {-# INLINE each #-}+#endif type family Index (s :: *) :: *