data-lens 2.0.0 → 2.0.1
raw patch · 2 files changed
+20/−7 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Lens.Common: getL :: Lens a b -> a -> b
+ Data.Lens.Common: modL :: Lens a b -> (b -> b) -> a -> a
+ Data.Lens.Common: setL :: Lens a b -> b -> a -> a
Files
- Data/Lens/Common.hs +19/−6
- data-lens.cabal +1/−1
Data/Lens/Common.hs view
@@ -4,6 +4,10 @@ , lens -- build a lens from a getter and setter , iso -- build a lens from an isomorphism -- * Functional API+ , getL+ , setL+ , modL+ -- * Operator API , (^$), (^$!) -- getter -- :: Lens a b -> a -> b , (^.), (^!) -- getter -- :: a -> Lens a b -> b , (^=), (^!=) -- setter -- :: Lens a b -> b -> (a -> a)@@ -62,11 +66,13 @@ iso :: (a -> b) -> (b -> a) -> Lens a b iso f g = Lens (store g . f) -infixr 0 ^$, ^$!+-- | Gets the getter function from a lens.+getL :: Lens a b -> a -> b+getL (Lens f) a = pos (f a) --- | functional getter+infixr 0 ^$, ^$! (^$), (^$!) :: Lens a b -> a -> b-Lens f ^$ a = pos (f a)+(^$) = getL Lens f ^$! a = pos (f $! a) infixr 9 ^., ^!@@ -75,17 +81,24 @@ a ^. Lens f = pos (f a) a ^! Lens f = pos (f $! a) +-- | Gets the setter function from a lens.+setL :: Lens a b -> b -> a -> a+setL (Lens f) b = peek b . f+ infixr 4 ^=, ^!=--- | functional setter (^=), (^!=) :: Lens a b -> b -> a -> a-Lens f ^= b = peek b . f+(^=) = setL Lens f ^!= b = \a -> case f a of StoreT (Identity g) _ -> g $! b +-- | Gets the modifier function from a lens.+modL :: Lens a b -> (b -> b) -> a -> a+modL (Lens f) g = peeks g . f+ infixr 4 ^%=, ^!%= -- | functional modify (^%=), (^!%=) :: Lens a b -> (b -> b) -> a -> a-Lens f ^%= g = peeks g . f+(^%=) = modL Lens f ^!%= g = \a -> case f a of StoreT (Identity h) b -> h $! g b
data-lens.cabal view
@@ -1,6 +1,6 @@ name: data-lens category: Control, Comonads-version: 2.0.0+version: 2.0.1 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE