Portability | ghc |
---|---|

Stability | unstable |

Maintainer | Andy Gill <andygill@ku.edu> |

This is the definition of the monad inside KURE.

- data RewriteM m dec exp
- data RewriteStatusM dec exp
- = RewriteReturnM exp !(Maybe dec) !IdStatus
- | RewriteFailureM String

- runRewriteM :: RewriteM m dec exp -> dec -> m (RewriteStatusM dec exp)
- failM :: (Monad m, Monoid dec) => String -> RewriteM m dec a
- catchM :: Monad m => RewriteM m dec a -> (String -> RewriteM m dec a) -> RewriteM m dec a
- chainM :: (Monoid dec, Monad m) => RewriteM m dec b -> (Bool -> b -> RewriteM m dec c) -> RewriteM m dec c
- liftQ :: (Monad m, Monoid dec) => m a -> RewriteM m dec a
- markM :: Monad m => RewriteM m dec a -> RewriteM m dec a
- transparently :: Monad m => RewriteM m dec a -> RewriteM m dec a
- getDecsM :: (Monad m, Monoid dec) => RewriteM m dec dec
- mapDecsM :: (Monad m, Monoid dec) => (dec -> dec) -> RewriteM m dec a -> RewriteM m dec a

# Documentation

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

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.