kure-0.2.1: Combinators for Strategic Programming

Portabilityghc
Stabilityunstable
MaintainerAndy Gill <andygill@ku.edu>

Language.KURE.Combinators

Contents

Description

This module contains various combinators that use Translate and Rewrite. The convension is that Translate based combinators end with T, and Rewrite based combinators end with R. Of course, because Rewrite is a type synomim of Translate, the Rewrite functions also operate with on Translate, and the Translate functions operate with Rewrite.

Synopsis

Translate combinators

(<+) :: (Monoid dec, Monad m) => Translate m dec a b -> Translate m dec a b -> Translate m dec a bSource

like a catch, <+ does the first translate , and if it fails, then does the second translate.

(>->) :: (Monoid dec, Monad m) => Translate m dec a b -> Translate m dec b c -> Translate m dec a cSource

like a ; If the first translate succeeds, then do to the second translate after the first translate.

failT :: (Monad m, Monoid dec) => String -> Translate m dec a bSource

failing translation.

(?) :: (Monoid dec, Monad m) => Bool -> Translate m dec a b -> Translate m dec a bSource

Guarded translate.

readerT :: (Monoid dec, Monad m) => (a -> Translate m dec a b) -> Translate m dec a bSource

look at the argument for the translation before choosing which translation to perform.

getDecsT :: (Monad m, Monoid dec) => (dec -> Translate m dec a b) -> Translate m dec a bSource

look at the dec before choosing which translation to do.

mapDecsT :: (Monoid dec, Monad m) => (dec -> dec) -> Translate m dec a r -> Translate m dec a rSource

change the dec's for a scoped translation.

pureT :: (Monad m, Monoid dec) => (a -> b) -> Translate m dec a bSource

pureT promotes a function into an unfailable, non-identity Translate.

constT :: (Monad m, Monoid dec) => b -> Translate m dec a bSource

constT always translates into an unfailable Translate that returns the first argument.

concatT :: (Monad m, Monoid dec, Monoid r) => [Translate m dec a r] -> Translate m dec a rSource

concatT composes a list of Translate into a single Translate which mconcats its result.

Rewrite combinators

(.+) :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec a -> Rewrite m dec aSource

if the first rewrite is an identity, then do the second rewrite.

(!->) :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec a -> Rewrite m dec aSource

if the first rewrite was not an identity, then also do the second rewrite.

tryR :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec aSource

catch a failing Rewrite, making it into an identity.

changedR :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec aSource

if this is an identity rewrite, make it fail. To succeed, something must have changed.

repeatR :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec aSource

repeat a rewrite until it fails, then return the result before the failure.

acceptR :: (Monoid dec, Monad m) => (a -> Bool) -> Rewrite m dec aSource

look at the argument to a rewrite, and choose to be either a failure of trivial success.

idR :: (Monad m, Monoid dec) => Rewrite m dec expSource

identity rewrite.

failR :: (Monad m, Monoid dec) => String -> Rewrite m dec aSource

failing rewrite.