fused-effects-lens 1.1.0.0 → 1.2.0.0
raw patch · 3 files changed
+38/−14 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.Effect.Lens: infixr 4 .=
+ Control.Effect.Lens: (<~) :: forall s a b sig m. Has (State s) sig m => ASetter s s a b -> m b -> m ()
+ Control.Effect.Lens: (?=) :: forall s a b sig m. Has (State s) sig m => ASetter s s a (Maybe b) -> b -> m ()
+ Control.Effect.Lens: infixr 2 <~
Files
- CHANGES.md +5/−0
- fused-effects-lens.cabal +3/−3
- src/Control/Effect/Lens.hs +30/−11
CHANGES.md view
@@ -1,3 +1,8 @@+# v1.2.0.0++Introduce `?=` and `<~`.+Change fixity of `.=` to `infix 4`.+ # v1.1.0.0 Introduce `+=`, `-=`, `*=`, and `//=`.
fused-effects-lens.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: fused-effects-lens-version: 1.1.0.0+version: 1.2.0.0 synopsis: Monadic lens combinators for fused-effects. description: Provides combinators for the lens-based manipulation of state and context types provided by the fused-effects library, similar to those provided for mtl-based monad transformers. homepage: https://github.com/fused-effects/fused-effects-lens#readme@@ -9,8 +9,8 @@ license-file: LICENSE author: Patrick Thomson maintainer: patrickt@github.com-copyright: 2018 Patrick Thomson-category: Web+copyright: 2018-2019 Patrick Thomson+category: Control build-type: Simple extra-source-files: README.md
src/Control/Effect/Lens.hs view
@@ -3,14 +3,20 @@ -- context types provided by the fused-effects library, similar to -- those provided for mtl-based monad transformers. module Control.Effect.Lens- ( Control.Effect.Lens.view+ ( -- * Reader accessors+ Control.Effect.Lens.view , views+ -- * State getters/setters , use , uses , assign- , (.=) , modifying+ -- * Infix operators+ , (.=)+ , (?=) , (%=)+ , (<~)+ -- * Mathematical operators , (+=) , (-=) , (*=)@@ -62,25 +68,38 @@ assign l b = State.modify (Lens.set l b) {-# INLINE assign #-} +-- | Map over the target of a 'Lens', or all of the targets of a @Setter@+-- or 'Traversal', in the current monadic state.+--+-- This is a prefix version of '%='.+modifying :: forall s a b sig m . (Has (State.State s) sig m) => ASetter s s a b -> (a -> b) -> m ()+modifying l f = State.modify (Lens.over l f)+{-# INLINE modifying #-}++infix 4 .=, %=, ?=, +=, -=, *=, //=+infixr 2 <~+ -- | Replace the target of a 'Lens' (or all the targets of a @Setter@ -- or 'Traversal') within the current monadic state, irrespective of -- the old value. -- -- This is an infix version of 'assign'.-infixr 4 .= (.=) :: forall s a b sig m . (Has (State.State s) sig m) => ASetter s s a b -> b -> m () (.=) = assign {-# INLINE (.=) #-} --- | Map over the target of a 'Lens', or all of the targets of a @Setter@--- or 'Traversal', in the current monadic state.------ This is a prefix version of '%='.-modifying :: forall s a b sig m . (Has (State.State s) sig m) => ASetter s s a b -> (a -> b) -> m ()-modifying l f = State.modify (Lens.over l f)-{-# INLINE modifying #-}+-- | Replace the target of a Lens or all of the targets of a @Setter@ or+-- 'Traversal' in our monadic state with Just a new value, irrespective+-- of the old.+(?=) :: forall s a b sig m . (Has (State.State s) sig m) => ASetter s s a (Maybe b) -> b -> m ()+setter ?= item = setter .= Just item+{-# INLINE (?=) #-} -infix 4 %=, +=, -=, *=, //=+-- | Run a monadic action, and set all of the targets of a 'Lens', @Setter@+-- or 'Traversal' to its result.+(<~) :: forall s a b sig m . (Has (State s) sig m) => ASetter s s a b -> m b -> m ()+setter <~ act = act >>= assign setter+{-# INLINE (<~) #-} -- | Map over the target of a 'Lens', or all of the targets of a @Setter@ -- or 'Traversal', in the current monadic state.