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

Stability | beta |

Maintainer | Neil Sculthorpe <neil@ittc.ku.edu> |

Safe Haskell | Safe-Inferred |

- idR :: Monad m => Rewrite c m a
- successT :: Monad m => Translate c m a ()
- contextT :: Monad m => Translate c m a c
- exposeT :: Monad m => Translate c m a (c, a)
- liftContext :: (c -> c') -> Translate c' m a b -> Translate c m a b
- readerT :: (a -> Translate c m a b) -> Translate c m a b
- resultT :: (m b -> n d) -> Translate c m a b -> Translate c n a d
- catchesT :: MonadCatch m => [Translate c m a b] -> Translate c m a b
- mapT :: (Traversable t, Monad m) => Translate c m a b -> Translate c m (t a) (t b)
- joinT :: Translate c m (m a) a
- guardT :: Monad m => Translate c m Bool ()
- tryR :: MonadCatch m => Rewrite c m a -> Rewrite c m a
- andR :: (Foldable f, Monad m) => f (Rewrite c m a) -> Rewrite c m a
- orR :: (Functor f, Foldable f, MonadCatch m) => f (Rewrite c m a) -> Rewrite c m a
- (>+>) :: MonadCatch m => Rewrite c m a -> Rewrite c m a -> Rewrite c m a
- repeatR :: MonadCatch m => Rewrite c m a -> Rewrite c m a
- acceptR :: Monad m => (a -> Bool) -> Rewrite c m a
- acceptWithFailMsgR :: Monad m => (a -> Bool) -> String -> Rewrite c m a
- accepterR :: Monad m => Translate c m a Bool -> Rewrite c m a
- changedR :: (MonadCatch m, Eq a) => Rewrite c m a -> Rewrite c m a
- changedByR :: MonadCatch m => (a -> a -> Bool) -> Rewrite c m a -> Rewrite c m a
- sideEffectR :: Monad m => (c -> a -> m ()) -> Rewrite c m a
- data AnyR m a
- wrapAnyR :: MonadCatch m => Rewrite c m a -> Rewrite c (AnyR m) a
- unwrapAnyR :: Monad m => Rewrite c (AnyR m) a -> Rewrite c m a
- data OneR m a
- wrapOneR :: MonadCatch m => Rewrite c m g -> Rewrite c (OneR m) g
- unwrapOneR :: Monad m => Rewrite c (OneR m) a -> Rewrite c m a

# Translate Combinators

liftContext :: (c -> c') -> Translate c' m a b -> Translate c m a bSource

Lift a `Translate`

to operate on a derived context.

resultT :: (m b -> n d) -> Translate c m a b -> Translate c n a dSource

Convert the monadic result of a `Translate`

into a result in another monad.

catchesT :: MonadCatch m => [Translate c m a b] -> Translate c m a bSource

mapT :: (Traversable t, Monad m) => Translate c m a b -> Translate c m (t a) (t b)Source

Map a `Translate`

over a list.

guardT :: Monad m => Translate c m Bool ()Source

Fail if the Boolean is False, succeed if the Boolean is True.

# Rewrite Combinators

tryR :: MonadCatch m => Rewrite c m a -> Rewrite c m aSource

Catch a failing `Rewrite`

, making it into an identity.

andR :: (Foldable f, Monad m) => f (Rewrite c m a) -> Rewrite c m aSource

Perform a collection of rewrites in sequence, requiring all to succeed.

orR :: (Functor f, Foldable f, MonadCatch m) => f (Rewrite c m a) -> Rewrite c m aSource

Perform a collection of rewrites in sequence, succeeding if any succeed.

(>+>) :: MonadCatch m => Rewrite c m a -> Rewrite c m a -> Rewrite c m aSource

Perform two rewrites in sequence, succeeding if one or both succeed.

repeatR :: MonadCatch m => Rewrite c m a -> Rewrite c m aSource

Repeat a `Rewrite`

until it fails, then return the result before the failure.
Requires at least the first attempt to succeed.

acceptWithFailMsgR :: Monad m => (a -> Bool) -> String -> Rewrite c m aSource

As `acceptR`

, but takes a custom failure message.

changedR :: (MonadCatch m, Eq a) => Rewrite c m a -> Rewrite c m aSource

Makes an `Rewrite`

fail if the result value equals the argument value.

changedByR :: MonadCatch m => (a -> a -> Bool) -> Rewrite c m a -> Rewrite c m aSource

sideEffectR :: Monad m => (c -> a -> m ()) -> Rewrite c m aSource

An identity `Rewrite`

with side-effects.

# Monad Transformers

## anyR Support

These are useful when defining congruence combinators that succeed if *any* child rewrite succeeds.
See the "Expr" example, or the HERMIT package.

The `AnyR`

transformer, in combination with `wrapAnyR`

and `unwrapAnyR`

,
causes a sequence of rewrites to succeed if at least one succeeds, converting failures to
identity rewrites.

Monad m => Monad (AnyR m) | |

MonadCatch m => MonadCatch (AnyR m) |

## oneR Support

These are useful when defining congruence combinators that succeed if one child rewrite succeeds (and the remainder are then discarded). See the "Expr" example, or the HERMIT package.

The `OneR`

transformer, in combination with `wrapOneR`

and `unwrapOneR`

,
causes a sequence of rewrites to only apply the first success, converting the remainder (and failures) to identity rewrites.

Monad m => Monad (OneR m) | |

MonadCatch m => MonadCatch (OneR m) |