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

Stability | unstable |

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

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`

.

- (<+) :: (Monoid dec, Monad m) => Translate m dec a b -> Translate m dec a b -> Translate m dec a b
- (>->) :: (Monoid dec, Monad m) => Translate m dec a b -> Translate m dec b c -> Translate m dec a c
- failT :: (Monad m, Monoid dec) => String -> Translate m dec a b
- readerT :: (Monoid dec, Monad m) => (a -> Translate m dec a b) -> Translate m dec a b
- getDecsT :: (Monad m, Monoid dec) => (dec -> Translate m dec a b) -> Translate m dec a b
- mapDecsT :: (Monoid dec, Monad m) => (dec -> dec) -> Translate m dec a r -> Translate m dec a r
- pureT :: (Monad m, Monoid dec) => (a -> b) -> Translate m dec a b
- constT :: (Monad m, Monoid dec) => b -> Translate m dec a b
- concatT :: (Monad m, Monoid dec, Monoid r) => [Translate m dec a r] -> Translate m dec a r
- (.+) :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec a -> Rewrite m dec a
- (!->) :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec a -> Rewrite m dec a
- tryR :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec a
- changedR :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec a
- repeatR :: (Monoid dec, Monad m) => Rewrite m dec a -> Rewrite m dec a
- acceptR :: (Monoid dec, Monad m) => (a -> Bool) -> Rewrite m dec a
- idR :: (Monad m, Monoid dec) => Rewrite m dec exp
- failR :: (Monad m, Monoid dec) => String -> Rewrite m dec a
- (?) :: Failable f => Bool -> f a -> f a
- class Failable f where

# The `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.

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.

# The `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.