rewriting-0.2.2: Generic rewriting library for regular datatypes.

Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org
Safe HaskellSafe-Infered

Generics.Regular.Rewriting.Machinery

Contents

Description

Summary: Core machinery for rewriting terms.

Synopsis

Type class synonym summarizing generic functions.

class (Regular a, Crush (PF a), GMap (PF a), Show (PF a), Zip (PF a), LR (PF a), Functor (PF a)) => Rewrite a Source

The Rewrite is a type class synonym, hiding some of the implementation details.

To be able to use the rewriting functions, the user is required to provide an instance of this type class.

Applying a rule specification to a term.

applyRuleM :: (Builder r, Rewrite (Target r), Monad m) => r -> Target r -> m (Target r)Source

Applies a rule specification to a term, obtaining a monadic value.

applyRule :: (Builder r, Rewrite (Target r)) => r -> Target r -> Target rSource

Applies a rule specification to a term, obtaining the original term when rewriting fails.

Rewriting a term.

rewriteM :: (Rewrite a, Monad m) => Rule a -> a -> m aSource

Rewrites a term, obtaining a monadic value.

rewrite :: Rewrite a => Rule a -> a -> aSource

Rewrites a term, obtaining the original term when rewriting fails.