kure-0.2: Combinators for Strategic Programming

MaintainerAndy Gill <andygill@ku.edu>



This is the definition of the monad inside KURE.



data RewriteM m dec exp Source


(Monoid dec, Monad m) => Monad (RewriteM m dec) 
(Monoid dec, Monad m) => Functor (RewriteM m dec) 

data RewriteStatusM dec exp Source


RewriteReturnM exp !(Maybe dec) !IdStatus

a regular success

RewriteFailureM String

a real failure | RewriteIdM exp -- ^ identity marker on a value

runRewriteM :: RewriteM m dec exp -> dec -> m (RewriteStatusM dec exp)Source

runRewriteM runs the RewriteM monad, returning a status.

failM :: (Monad m, Monoid dec) => String -> RewriteM m dec aSource

failM is our basic failure, with a String message.

catchM :: Monad m => RewriteM m dec a -> (String -> RewriteM m dec a) -> RewriteM m dec aSource

catchM catches failures, and tries a second monadic computation.

chainM :: (Monoid dec, Monad m) => RewriteM m dec b -> (Bool -> b -> RewriteM m dec c) -> RewriteM m dec cSource

chainM executes the first argument then the second, much like >>=, except that the second computation can see if the first computation was an identity or not. Used to spot when a rewrite succeeded, but was the identity.

liftQ :: (Monad m, Monoid dec) => m a -> RewriteM m dec aSource

liftQ lets you tunnel into the inner monad, because RewriteM is actually monad transformer.

markM :: Monad m => RewriteM m dec a -> RewriteM m dec aSource

markM is used to mark a monadic rewrite as a non-identity, unless the congruence flag is set.

transparently :: Monad m => RewriteM m dec a -> RewriteM m dec aSource

transparently sets the congruence flag, such that if the monadic action was identity preserving, then a markM does not set the non-indentity flag.

getDecsM :: (Monad m, Monoid dec) => RewriteM m dec decSource

getDecsM reads the local environment

mapDecsM :: (Monad m, Monoid dec) => (dec -> dec) -> RewriteM m dec a -> RewriteM m dec aSource