Portability | Rank2Types |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Safe-Inferred |
This module exports a minimalist API for working with lenses in highly monomorphic settings.
- type ALens s t a b = LensLike (Pretext (->) a b) s t a b
- type ALens' s a = ALens s s a a
- cloneLens :: ALens s t a b -> Lens s t a b
- storing :: ALens s t a b -> b -> s -> t
- (^#) :: s -> ALens s t a b -> a
- (#~) :: ALens s t a b -> b -> s -> t
- (#%~) :: ALens s t a b -> (a -> b) -> s -> t
- (#%%~) :: Functor f => ALens s t a b -> (a -> f b) -> s -> f t
- (<#~) :: ALens s t a b -> b -> s -> (b, t)
- (<#%~) :: ALens s t a b -> (a -> b) -> s -> (b, t)
- (#=) :: MonadState s m => ALens s s a b -> b -> m ()
- (#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m ()
- (#%%=) :: MonadState s m => ALens s s a b -> (a -> (r, b)) -> m r
- (<#=) :: MonadState s m => ALens s s a b -> b -> m b
- (<#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m b
- type Loupe s t a b = LensLike (Pretext (->) a b) s t a b
- type SimpleLoupe s a = Loupe s s a a
Documentation
cloneLens :: ALens s t a b -> Lens s t a bSource
Cloning a Lens
is one way to make sure you aren't given
something weaker, such as a Traversal
and can be
used as a way to pass around lenses that have to be monomorphic in f
.
Note: This only accepts a proper Lens
.
>>>
let example l x = set (cloneLens l) (x^.cloneLens l + 1) x in example _2 ("hello",1,"you")
("hello",2,"you")
(#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m ()Source
(#%%=) :: MonadState s m => ALens s s a b -> (a -> (r, b)) -> m rSource
(<#%=) :: MonadState s m => ALens s s a b -> (a -> b) -> m bSource
Deprecated Aliases
type Loupe s t a b = LensLike (Pretext (->) a b) s t a bSource
Deprecated: use ALens
This is an older alias for a type-restricted form of lens that is able to be passed around in containers monomorphically.
Deprecated. This has since been renamed to ALens
for consistency.
type SimpleLoupe s a = Loupe s s a aSource