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

Stability | beta |

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

Safe Haskell | Safe-Inferred |

A bi-directional translation is a translation that can be applied in either direction.

- data BiTranslate c m a b
- type BiRewrite c m a = BiTranslate c m a a
- bidirectional :: Translate c m a b -> Translate c m b a -> BiTranslate c m a b
- forewardT :: BiTranslate c m a b -> Translate c m a b
- backwardT :: BiTranslate c m a b -> Translate c m b a
- whicheverR :: MonadCatch m => BiRewrite c m a -> Rewrite c m a
- invertBiT :: BiTranslate c m a b -> BiTranslate c m b a
- beforeBiR :: Monad m => Translate c m a b -> (b -> BiRewrite c m a) -> BiRewrite c m a

# Bi-directional Translations

type BiRewrite c m a = BiTranslate c m a aSource

A `BiTranslate`

that shares the same source and target type.

bidirectional :: Translate c m a b -> Translate c m b a -> BiTranslate c m a bSource

Construct a `BiTranslate`

from two opposite `Translate`

s.

forewardT :: BiTranslate c m a b -> Translate c m a bSource

Extract the foreward `Translate`

from a `BiTranslate`

.

backwardT :: BiTranslate c m a b -> Translate c m b aSource

Extract the backward `Translate`

from a `BiTranslate`

.

whicheverR :: MonadCatch m => BiRewrite c m a -> Rewrite c m aSource

Try the `BiRewrite`

forewards, then backwards if that fails.
Useful when you know which rule you want to apply, but not which direction to apply it in.

invertBiT :: BiTranslate c m a b -> BiTranslate c m b aSource

Invert the forewards and backwards directions of a `BiTranslate`

.