rewriting-0.2: Generic rewriting library for regular datatypes.Source codeContentsIndex
Generics.Regular.Rewriting.Rules
Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org
Contents
Rule specification.
Representation of a rule.
Builder for transforming a rule specification to a rule.
Description
Summary: Functions for transforming a rule specification to a rule.
Synopsis
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
= Metavar Metavar
| PF (f (Scheme f))
schemeView :: Scheme f -> SchemeView f
foldScheme :: Functor f => (Metavar -> a) -> (f a -> a) -> Scheme f -> a
class Regular (Target a) => Builder a where
type Target a :: *
base :: a -> RuleSpec (Target a)
diag :: a -> [RuleSpec (Target a)]
ruleM :: (Builder r, CrushR (PF (Target r)), Zip (PF (Target r)), Functor (PF (Target r))) => r -> Maybe (Rule (Target r))
rule :: (Builder r, CrushR (PF (Target r)), Functor (PF (Target r)), Zip (PF (Target r))) => r -> Rule (Target r)
Rule specification.
data RuleSpec a Source
Specifies a rule as a value of a datatype.
Constructors
a :~> a
show/hide Instances
lhsR :: RuleSpec a -> aSource
Returns the left-hand side of a rule.
rhsR :: RuleSpec a -> aSource
Returns the right-hand side of a rule.
Representation of a rule.
type Rule a = RuleSpec (SchemeOf a)Source
Allows metavariables on either side of a rule.
type SchemeOf a = Scheme (PF a)Source
Extends the pattern functor of a value.
type Metavar = IntSource
metavar :: Metavar -> Scheme fSource
Constructs a metavariable.
pf :: f (Scheme f) -> Scheme fSource
Constructs a pattern functor value.
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.
Constructors
Metavar Metavar
PF (f (Scheme f))
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.
Associated Types
type Target a :: *Source
Methods
base :: a -> RuleSpec (Target a)Source
diag :: a -> [RuleSpec (Target a)]Source
show/hide Instances
Regular a => Builder (RuleSpec a)
(Builder a, Regular b, LR (PF b)) => Builder (b -> a)
ruleM :: (Builder r, CrushR (PF (Target r)), Zip (PF (Target r)), Functor (PF (Target r))) => r -> Maybe (Rule (Target r))Source
Transforms a rule specification to a rule and returns Nothing if an unbound metavariable occurs in the right-hand side of the rule.
rule :: (Builder r, CrushR (PF (Target r)), Functor (PF (Target r)), Zip (PF (Target r))) => r -> Rule (Target r)Source
Transforms a rule specification to a rule and throws a runtime error if an unbound metavariable occurs in the right-hand side of the rule.
Produced by Haddock version 2.4.2