Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Default lenses for simple total getters and total possibly polymorphic, updates. Useful for creating accessor labels for single constructor datatypes. Also useful field labels that are shared between all the constructors of a multi constructor datatypes.
Synopsis
- type (:->) f o = Lens Total f o
- type Total = (->)
- lens :: (f -> o) -> ((o -> i) -> f -> g) -> (f -> g) :-> (o -> i)
- get :: ((f -> g) :-> (o -> i)) -> f -> o
- modify :: ((f -> g) :-> (o -> i)) -> (o -> i) -> f -> g
- set :: ((f -> g) :-> (o -> i)) -> i -> f -> g
- traverse :: Functor m => ((f -> g) :-> (o -> i)) -> (o -> m i) -> f -> m g
- lifted :: Monad m => ((f -> g) :-> (m o -> m i)) -> ((o -> i) :-> (m a -> m b)) -> (f -> g) :-> (m a -> m b)
Documentation
:: (f -> o) | Getter. |
-> ((o -> i) -> f -> g) | Modifier. |
-> (f -> g) :-> (o -> i) |
Create a total lens from a getter and a modifier.
We expect the following law to hold:
get l (set l a f) == a
set l (get l f) f == f
modify :: ((f -> g) :-> (o -> i)) -> (o -> i) -> f -> g Source #
Get the modifier function from a lens.