alloy-1.2.2: Generic programming library

Safe HaskellSafe
LanguageHaskell98

Data.Generics.Alloy.Pure

Description

The module containing the Alloy type-class for working with pure functions (of the type a -> a).

Synopsis

Documentation

class Alloy t o o' where Source

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).

Methods

transform :: o -> o' -> t -> t Source

type Recurse opT = forall t. Alloy t opT BaseOp => t -> t Source

A type representing a modifier function that applies the given ops (opT) directly to the given type (t).

makeRecurse :: opT -> Recurse opT Source

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 -> t Source

A type representing a modifier function that applies the given ops (opT) to the children of the given type (t).

makeDescend :: opT -> Descend opT Source

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.

data BaseOp Source

The type of the empty set of pure operations.

Constructors

BaseOp 

baseOp :: BaseOp Source

The function giving the empty set of pure operations.

data t :- opT infixr 7 Source

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

Constructors

(t -> t) :- opT infixr 7 

type OneOp t = t :- BaseOp Source

A handy synonym for an opset with only one item, to use with Alloy.

type TwoOp s t = s :- (t :- BaseOp) Source

A handy synonym for an opset with only two items, to use with Alloy.