Safe Haskell | Safe-Inferred |
---|
The module containing the Alloy type-class for working with pure functions
(of the type a -> a
).
- class Alloy t o o' where
- transform :: o -> o' -> t -> t
- type Recurse opT = forall t. Alloy t opT BaseOp => t -> t
- makeRecurse :: opT -> Recurse opT
- type Descend opT = forall t. Alloy t BaseOp opT => t -> t
- makeDescend :: opT -> Descend opT
- data BaseOp = BaseOp
- baseOp :: BaseOp
- data t :- opT = (t -> t) :- opT
- type OneOp t = t :- BaseOp
- type TwoOp s t = s :- (t :- BaseOp)
Documentation
class Alloy t o o' whereSource
The Alloy type-class for pure functions, to be used with sets of
operations constructed from BaseOp
and :-
. You are unlikely to need to
use transform
directly; instead use makeRecurse
and makeDescend
.
The first parameter to the type-class is the type currently being operated on, the second parameter is the set of operations to perform directly on the type, and the third parameter is the set of operations to perform on its children (if none of the second parameter operations can be applied).
type Recurse opT = forall t. Alloy t opT BaseOp => t -> tSource
A type representing a modifier function that applies the given ops (opT) directly to the given type (t).
makeRecurse :: opT -> Recurse opTSource
Given a set of operations, makes a modifier function that applies the operations directly to the given type, and then to its children, until it has been applied to all the largest instances of that type.
type Descend opT = forall t. Alloy t BaseOp opT => t -> tSource
A type representing a modifier function that applies the given ops (opT) to the children of the given type (t).
makeDescend :: opT -> Descend opTSource
Given a set of operations, makes a descent modifier function that applies the operation to the type's children, and further down, until it has been applied to all the largest instances of that type.
The type that extends an opset (opT) to be applied to the given type (t).
This is for use with the Alloy
type-class. A set of operations that operates
on Foo
, Bar
and Baz
can be constructed so:
ops :: Foo :- Bar :- Baz :- BaseOp ops = doFoo :- doBar :- doBaz :- baseOp doFoo :: Foo -> Foo doBar :: Bar -> Bar doBaz :: Baz -> Baz
(t -> t) :- opT |