This module defines the `Accessor`

type.
It should be imported with qualification.

- data T r a
- fromSetGet :: (a -> r -> r) -> (r -> a) -> T r a
- fromLens :: (r -> (a, a -> r)) -> T r a
- set :: T r a -> a -> r -> r
- (^=) :: T r a -> a -> r -> r
- compose :: [r -> r] -> r -> r
- get :: T r a -> r -> a
- (^.) :: r -> T r a -> a
- modify :: T r a -> (a -> a) -> r -> r
- (^:) :: T r a -> (a -> a) -> r -> r
- (.>) :: T a b -> T b c -> T a c
- (<.) :: T b c -> T a b -> T a c
- ($%) :: a -> (a -> b) -> b

# Documentation

The access functions we propose, look very similar to those needed for List.mapAccumL (but parameter order is swapped) and State monad. They get the new value of the field and the record and return the old value of the field and the record with the updated field.

fromSetGet :: (a -> r -> r) -> (r -> a) -> T r aSource

(^=) :: T r a -> a -> r -> rSource

`set`

as infix operator.
This lets us write `first ^= 2+3 $ second ^= 5+7 $ record`

.

compose :: [r -> r] -> r -> rSource

This is a general function, but it is especially useful for setting many values of different type at once.

`get`

as infix operator.
This lets us write `record^.field^.subfield`

.
This imitates Modula II syntax.

(^:) :: T r a -> (a -> a) -> r -> rSource

`modify`

as infix operator.
This lets us write
`field^:subfield^:(2*) $ record`

,
`record$%field^:subfield^:(2*)`

or `record$%field^:subfield^:(const 1)`

.