kure-0.3.1: Combinators for Strategic Programming

Portabilityghc
Stabilityunstable
MaintainerAndy Gill <andygill@ku.edu>

Language.KURE.Rewrite

Description

Rewrite is a synonoym for a Translate with the same source and target type. This module contains the defintion of Rewrite, and some aliases for some translate functions that use Rewrite rather than Translate.

Synopsis

Documentation

type Rewrite m dec exp = Translate m dec exp expSource

A Rewrite is a Translate that shares the same source and target type. Literally, a Rewrite provides the details about how to re-write a specific type.

rewrite :: (Monoid dec, Monad m) => (exp1 -> RewriteM m dec exp1) -> Rewrite m dec exp1Source

rewrite is our primitive way of building a Rewrite, where if the rewrite is successful it is automatically marked as a non-identity rewrite.

rewrite $ \ _ e -> return e is not an identity rewrite.

runRewrite :: (Monoid dec, Monad m) => Rewrite m dec exp -> dec -> exp -> m (Either String (exp, dec, Int))Source

runRewrite executes the rewrite, returning either a failure message, or a success and the new parts of the environment.