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) !Count
- | RewriteFailureM String

- data Count
- = LoneTransform
- | Count !Int

- theCount :: Count -> Int
- 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 -> (Int -> 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
- transparentlyM :: Monad m => RewriteM m dec a -> RewriteM m dec a
- readEnvM :: (Monad m, Monoid dec) => RewriteM m dec dec
- mapEnvM :: (Monad m, Monoid dec) => (dec -> dec) -> RewriteM m dec a -> RewriteM m dec a
- writeEnvM :: (Monad m, Monoid dec) => dec -> RewriteM m dec ()

# Documentation

data RewriteStatusM dec exp Source

RewriteReturnM exp !(Maybe dec) !Count | 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 -> (Int -> 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.

transparentlyM :: 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.