microlens 0.3.1.0 → 0.3.2.0
raw patch · 4 files changed
+46/−3 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Lens.Micro: instance Applicative (Bazaar a b)
- Lens.Micro: instance Functor (Bazaar a b)
- Lens.Micro.Internal: instance (a ~ b, a ~ c, a ~ d, a ~ e, q ~ r, q ~ s, q ~ t, q ~ u) => Each (a, b, c, d, e) (q, r, s, t, u) a q
- Lens.Micro.Internal: instance (a ~ b, a ~ c, a ~ d, q ~ r, q ~ s, q ~ t) => Each (a, b, c, d) (q, r, s, t) a q
- Lens.Micro.Internal: instance (a ~ b, a ~ c, q ~ r, q ~ s) => Each (a, b, c) (q, r, s) a q
- Lens.Micro.Internal: instance (a ~ b, q ~ r) => Each (a, b) (q, r) a q
- Lens.Micro.Internal: instance Cons [a] [b] a b
- Lens.Micro.Internal: instance Each (Complex a) (Complex b) a b
- Lens.Micro.Internal: instance Each (Maybe a) (Maybe b) a b
- Lens.Micro.Internal: instance Each [a] [b] a b
- Lens.Micro.Internal: instance Eq e => Ixed (e -> a)
- Lens.Micro.Internal: instance Field1 (a, b) (a', b) a a'
- Lens.Micro.Internal: instance Field1 (a, b, c) (a', b, c) a a'
- Lens.Micro.Internal: instance Field1 (a, b, c, d) (a', b, c, d) a a'
- Lens.Micro.Internal: instance Field1 (a, b, c, d, e) (a', b, c, d, e) a a'
- Lens.Micro.Internal: instance Field2 (a, b) (a, b') b b'
- Lens.Micro.Internal: instance Field2 (a, b, c) (a, b', c) b b'
- Lens.Micro.Internal: instance Field2 (a, b, c, d) (a, b', c, d) b b'
- Lens.Micro.Internal: instance Field2 (a, b, c, d, e) (a, b', c, d, e) b b'
- Lens.Micro.Internal: instance Field3 (a, b, c) (a, b, c') c c'
- Lens.Micro.Internal: instance Field3 (a, b, c, d) (a, b, c', d) c c'
- Lens.Micro.Internal: instance Field3 (a, b, c, d, e) (a, b, c', d, e) c c'
- Lens.Micro.Internal: instance Field4 (a, b, c, d) (a, b, c, d') d d'
- Lens.Micro.Internal: instance Field4 (a, b, c, d, e) (a, b, c, d', e) d d'
- Lens.Micro.Internal: instance Field5 (a, b, c, d, e) (a, b, c, d, e') e e'
- Lens.Micro.Internal: instance Ixed [a]
- Lens.Micro.Internal: instance Snoc [a] [b] a b
+ Lens.Micro: instance GHC.Base.Applicative (Lens.Micro.Bazaar a b)
+ Lens.Micro: instance GHC.Base.Functor (Lens.Micro.Bazaar a b)
+ Lens.Micro: to :: (s -> a) -> Getting r s a
+ Lens.Micro: toListOf :: Getting (Endo [a]) s a -> s -> [a]
+ Lens.Micro.Internal: instance (a ~ b, a ~ c, a ~ d, a ~ e, q ~ r, q ~ s, q ~ t, q ~ u) => Lens.Micro.Internal.Each (a, b, c, d, e) (q, r, s, t, u) a q
+ Lens.Micro.Internal: instance (a ~ b, a ~ c, a ~ d, q ~ r, q ~ s, q ~ t) => Lens.Micro.Internal.Each (a, b, c, d) (q, r, s, t) a q
+ Lens.Micro.Internal: instance (a ~ b, a ~ c, q ~ r, q ~ s) => Lens.Micro.Internal.Each (a, b, c) (q, r, s) a q
+ Lens.Micro.Internal: instance (a ~ b, q ~ r) => Lens.Micro.Internal.Each (a, b) (q, r) a q
+ Lens.Micro.Internal: instance GHC.Classes.Eq e => Lens.Micro.Internal.Ixed (e -> a)
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Cons [a] [b] a b
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Each (Data.Complex.Complex a) (Data.Complex.Complex b) a b
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Each (GHC.Base.Maybe a) (GHC.Base.Maybe b) a b
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Each [a] [b] a b
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field1 (a, b) (a', b) a a'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field1 (a, b, c) (a', b, c) a a'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field1 (a, b, c, d) (a', b, c, d) a a'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field1 (a, b, c, d, e) (a', b, c, d, e) a a'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field2 (a, b) (a, b') b b'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field2 (a, b, c) (a, b', c) b b'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field2 (a, b, c, d) (a, b', c, d) b b'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field2 (a, b, c, d, e) (a, b', c, d, e) b b'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field3 (a, b, c) (a, b, c') c c'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field3 (a, b, c, d) (a, b, c', d) c c'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field3 (a, b, c, d, e) (a, b, c', d, e) c c'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field4 (a, b, c, d) (a, b, c, d') d d'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field4 (a, b, c, d, e) (a, b, c, d', e) d d'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Field5 (a, b, c, d, e) (a, b, c, d, e') e e'
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Ixed [a]
+ Lens.Micro.Internal: instance Lens.Micro.Internal.Snoc [a] [b] a b
+ Lens.Micro.Internal: phantom :: Const r a -> Const r b
Files
- CHANGELOG.md +5/−0
- microlens.cabal +1/−1
- src/Lens/Micro.hs +39/−2
- src/Lens/Micro/Internal.hs +1/−0
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.3.2.0++* Added `toListOf` back.+* Added `to`.+ # 0.3.1.0 * Added `LensLike` and `LensLike'`.
microlens.cabal view
@@ -1,5 +1,5 @@ name: microlens-version: 0.3.1.0+version: 0.3.2.0 synopsis: A tiny part of the lens library which you can depend upon description: This is an extract from <http://hackage.haskell.org/package/lens lens> (with no dependencies). It's not a toy lenses library, unsuitable for “real world”, but merely a small one. It is compatible with lens, and should have same performance. It also has better documentation.
src/Lens/Micro.hs view
@@ -25,10 +25,11 @@ -- $getters-note Getting, (^.),+ to, -- * Folds (getters returning multiple elements) -- $folds-note- (^..),+ (^..), toListOf, (^?), (^?!), folded,@@ -307,6 +308,35 @@ infixl 8 ^. +{- |+'to' creates a getter from any function:++@+a '^.' 'to' f = f a+@++It's most useful in chains, because it lets you mix lenses and ordinary functions. Suppose you have a record which comes from some third-party library and doesn't have any lens accessors. You want to do something like this:++@+value ^. _1 . field . at 2+@++However, @field@ isn't a getter, and you have to do this instead:++@+field (value ^. _1) ^. at 2+@++but now @value@ is in the middle and it's hard to read the resulting code. A variant with 'to' is prettier and more readable:++@+value ^. _1 . to field . at 2+@+-}+to :: (s -> a) -> Getting r s a+to k f = phantom . f . k+{-# INLINE to #-}+ -- Folds ------------------------------------------------------------------- {- $folds-note@@ -354,10 +384,17 @@ [1,2,3,4] -} (^..) :: s -> Getting (Endo [a]) s a -> [a]-s ^.. l = foldrOf l (:) [] s+s ^.. l = toListOf l s {-# INLINE (^..) #-} infixl 8 ^..++{- |+'toListOf' is a synonym for ('^..').+-}+toListOf :: Getting (Endo [a]) s a -> s -> [a]+toListOf l = foldrOf l (:) []+{-# INLINE toListOf #-} {- | @s ^? t@ returns the 1st element @t@ returns, or 'Nothing' if @t@ doesn't return anything. It's trivially implemented by passing the 'First' monoid to the getter.
src/Lens/Micro/Internal.hs view
@@ -30,6 +30,7 @@ sets, ( #. ), ( .# ),+ phantom, Each(..), Index, IxValue,