- type Getter f o = f -> o
- type Setter f i = i -> f -> f
- type Modifier f i o = (o -> i) -> f -> f
- data Point f i o
- newtype f :-> a = Label (Point f a a)
- label :: Getter f a -> Setter f a -> f :-> a
- get :: (f :-> a) -> f -> a
- set :: (f :-> a) -> a -> f -> f
- mod :: (f :-> a) -> (a -> a) -> f -> f
- fmapL :: Applicative f => (a :-> b) -> f a :-> f b
- data a :<->: b = Lens {}
- (<->) :: (a -> b) -> (b -> a) -> a :<->: b
- class Iso f where
- lmap :: Functor f => (a :<->: b) -> f a :<->: f b
- for :: (i -> o) -> (f :-> o) -> Point f i o
- getM :: MonadState s m => (s :-> b) -> m b
- setM :: MonadState s m => (s :-> b) -> b -> m ()
- modM :: MonadState s m => (s :-> b) -> (b -> b) -> m ()
- (=:) :: MonadState s m => (s :-> b) -> b -> m ()
- mkLabels :: [Name] -> Q [Dec]
Getter, setter and modifier types.
Label type.
fmapL :: Applicative f => (a :-> b) -> f a :-> f bSource
Bidirectional functor.
The lens datatype, a function that works in two directions. To bad there is no convenient way to do application for this.
This isomorphism type class is like a Functor
but works in two directions.
for :: (i -> o) -> (f :-> o) -> Point f i oSource
Combine a partial destructor with a label into something easily used in
the applicative instance for the hidden Point
datatype. Internally uses
the covariant in getter, contravariant in setter bi-functioral-map function.
(Please refer to the example because this function is just not explainable
on its own.)
State monadic label operations.
getM :: MonadState s m => (s :-> b) -> m bSource
Get a value out of state pointed to by the specified label.
setM :: MonadState s m => (s :-> b) -> b -> m ()Source
Set a value somewhere in state pointed to by the specified label.
modM :: MonadState s m => (s :-> b) -> (b -> b) -> m ()Source
Modify a value with a function somewhere in state pointed to by the specified label.