|
|
|
Description |
This module provides a simple abstract data type for
a piece of a data stucture that can be read from and
written to.
In contrast to Data.Accessor.Basic it is intended for unqualified import.
|
|
Synopsis |
|
|
|
Documentation |
|
|
An Accessor r a is an object that encodes how to
get and put a subject of type a out of/into an object
of type s.
In order for an instance of this data structure a to be
an Accessor, it must obey the following laws:
getVal a (setVal a x r) = x
setVal a (getVal a r) r = r
|
|
|
:: | | => r -> a | get method
| -> a -> r -> r | set method
| -> Accessor r a | | Construct an Accessor from a get and a set method.
|
|
|
|
:: | | => Accessor r a | record field f
| -> a | value x to be set
| -> r | original record
| -> r | new record with field f changed to x
| Set a value of a record field that is specified by an Accessor
|
|
|
|
set as infix operator.
This lets us write first ^= 2+3 $ second ^= 5+7 $ record.
|
|
|
:: | | => Accessor r a | record field
| -> r | record
| -> a | value of the field in the record
| Get a value from a record field that is specified by an Accessor
|
|
|
|
get as infix operator.
This lets us write record^.field^.subfield.
This imitates Modula II syntax.
|
|
(^:) :: T r a -> (a -> a) -> r -> r | Source |
|
modify as infix operator.
This lets us write
field^:subfield^:(2*) $ record,
record$%field^:subfield^:(2*)
or record$%field^:subfield^:(const 1).
|
|
|
A structural dereference function for state monads.
|
|
|
A structural assignment function for state monads.
|
|
|
An "assignment operator" for state monads.
(=:) = putA
|
|
|
Infix variant of set.
|
|
|
A structural modification function for state monads.
|
|
|
Infix variant of modify.
|
|
|
Accessor composition:
Combine an accessor with an accessor to a sub-field.
Speak "stack".
|
|
|
Accessor composition the other direction.
(<.) = flip (.>)
|
|
Produced by Haddock version 2.4.2 |