packages feed

microlens 0.1.5.0 → 0.2.0.0

raw patch · 4 files changed

+46/−46 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Lens.Micro: toListOf :: Getting (Endo [a]) s a -> s -> [a]
- Lens.Micro.Extras: (*~) :: Num a => ASetter s t a a -> a -> s -> t
- Lens.Micro.Extras: (+~) :: Num a => ASetter s t a a -> a -> s -> t
- Lens.Micro.Extras: (-~) :: Num a => ASetter s t a a -> a -> s -> t
- Lens.Micro.Extras: (//~) :: Fractional a => ASetter s t a a -> a -> s -> t

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.2.0.0++* Removed `toListOf`.+* Removed `+~`, `-~`, `*~`, `//~` and the `Lens.Micro.Extras` module.+ # 0.1.5.0  * Added `ix` and `at`.
microlens.cabal view
@@ -1,5 +1,5 @@ name:                microlens-version:             0.1.5.0+version:             0.2.0.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.@@ -38,7 +38,6 @@  library   exposed-modules:     Lens.Micro-                       Lens.Micro.Extras                        Lens.Micro.Classes                        Lens.Micro.Internal                        Lens.Micro.Type
src/Lens/Micro.hs view
@@ -26,7 +26,8 @@   (^.),    -- * Folds (getters returning multiple elements)-  (^..), toListOf,+  -- $folds-note+  (^..),   (^?),   (^?!),   folded,@@ -249,6 +250,37 @@  -- Folds ------------------------------------------------------------------- +{- $folds-note++Folds are getters that can traverse more than one element (or no elements at all). The only fold here which isn't simultaneously a 'Traversal' is 'folded' (traversals are folds that also can modify elements they're traversing).++You can apply folds to values by using operators like ('^..'), ('^?'), etc:++>>> (1,2) ^.. both+[1,2]++A nice thing about folds is that you can combine them with ('Data.Monoid.<>') to concatenate their outputs:++>>> (1,2,3) ^.. (_2 <> _1)  -- in reversed order because why not+[2,1]++You can build more complicated getters with it when 'each' would be unhelpful:++>>> ([1,2], 3, [Nothing, Just 4]) ^.. (_1.each <> _2 <> _3.each._Just)+[1,2,3,4]++It plays nicely with ('^?'), too:++>>> [0..9] ^? (ix 9 <> ix 5)+Just 9+>>> [0..8] ^? (ix 9 <> ix 5)+Just 5+>>> [0..3] ^? (ix 9 <> ix 5)+Nothing++(Unfortunately, this trick won't help you with setting or modifying.)+-}+ {- | @s ^.. t@ returns the list of all values that @t@ gets from @s@. @@ -263,19 +295,12 @@ [1,2,3,4] -} (^..) :: s -> Getting (Endo [a]) s a -> [a]-s ^.. l = toListOf l s+s ^.. l = foldrOf 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.  Safe 'head':@@ -377,7 +402,7 @@  {- $prisms-note -Prisms are traversals which always target 0 or 1 values. Moreover, it's possible to /reverse/ a prism, using it to construct a structure instead of peeking into it. Here's an example from the lens library:+Prisms are traversals that always target 0 or 1 values. Moreover, it's possible to /reverse/ a prism, using it to construct a structure instead of peeking into it. Here's an example from the lens library:  @ >>> over _Left (+1) (Left 2)@@ -393,12 +418,10 @@ {- | '_Left' targets the value contained in an 'Either', provided it's a 'Left'. -Gathering all @Left@s in a structure (like the 'Data.Either.lefts' function):+Gathering all @Left@s in a structure (like the 'Data.Either.lefts' function, but not necessarily just for lists): -@-'toListOf' ('each' '.' '_Left') :: ['Either' a b] -> [a]-'toListOf' ('each' '.' '_Left') = 'Data.Either.lefts'-@+>>> [Left 1, Right 'c', Left 3] ^.. each._Just+[1,3]  Checking whether an 'Either' is a 'Left' (like 'Data.Either.isLeft'): @@ -413,7 +436,7 @@ >>> Left 1 ^?! _Left 1 -Mapping over all @Left@s:+Mapping over all 'Left's:  >>> (each._Left %~ map toUpper) [Left "foo", Right "bar"] [Left "FOO",Right "bar"]@@ -463,7 +486,7 @@     'Data.Maybe.maybeToList' = ('^..' '_Just')     @ -  * Gathering all @Just@s in a list:+  * Gathering all 'Just's in a list:      @     'Data.Maybe.catMaybes' = ('^..' 'each' '.' '_Just')
− src/Lens/Micro/Extras.hs
@@ -1,27 +0,0 @@-module Lens.Micro.Extras-(-  (+~), (-~), (*~), (//~),-)-where---import Lens.Micro---infixr 4 +~, -~, *~, //~--(+~) :: Num a => ASetter s t a a -> a -> s -> t-l +~ n = over l (+ n)-{-# INLINE (+~) #-}--(*~) :: Num a => ASetter s t a a -> a -> s -> t-l *~ n = over l (* n)-{-# INLINE (*~) #-}--(-~) :: Num a => ASetter s t a a -> a -> s -> t-l -~ n = over l (subtract n)-{-# INLINE (-~) #-}--(//~) :: Fractional a => ASetter s t a a -> a -> s -> t-l //~ n = over l (/ n)-{-# INLINE (//~) #-}