Portability | non-portable |
---|---|

Stability | experimental |

Maintainer | generics@haskell.org |

Safe Haskell | Safe-Infered |

Summary: Functions for transforming a rule specification to a rule.

- data RuleSpec a = a :~> a
- lhsR :: RuleSpec a -> a
- rhsR :: RuleSpec a -> a
- type Rule a = RuleSpec (SchemeOf a)
- type SchemeOf a = Scheme (PF a)
- type Metavar = Int
- metavar :: Metavar -> Scheme f
- pf :: f (Scheme f) -> Scheme f
- toScheme :: (Regular a, Functor (PF a)) => a -> SchemeOf a
- data SchemeView f
- schemeView :: Scheme f -> SchemeView f
- foldScheme :: Functor f => (Metavar -> a) -> (f a -> a) -> Scheme f -> a
- class Regular (Target a) => Builder a where
- ruleM :: (Builder r, Crush (PF (Target r)), Zip (PF (Target r)), Functor (PF (Target r))) => r -> Maybe (Rule (Target r))
- rule :: (Builder r, Crush (PF (Target r)), Functor (PF (Target r)), Zip (PF (Target r))) => r -> Rule (Target r)

# Rule specification.

Specifies a rule as a value of a datatype.

a :~> a |

# Representation of a rule.

toScheme :: (Regular a, Functor (PF a)) => a -> SchemeOf aSource

Recursively converts a value to a `SchemeOf`

value.

data SchemeView f Source

A view on schemes to easily distinguish metavariables from pattern functor values.

schemeView :: Scheme f -> SchemeView fSource

Returns the value corresponding to the `SchemeView`

.

foldScheme :: Functor f => (Metavar -> a) -> (f a -> a) -> Scheme f -> aSource

Folds a `Scheme`

value given a function to apply to metavariables and a
function to apply to a pattern functor value.

# Builder for transforming a rule specification to a rule.

class Regular (Target a) => Builder a whereSource

The type class `Builder`

captures the functions, that are defined by
induction on the type argument, that construct appropriate `left`

and
`right`

values. These values are used to transform a rule specification
to a rule.