Portability | ghc |
---|---|
Stability | beta |
Maintainer | Neil Sculthorpe <neil@ittc.ku.edu> |
Safe Haskell | Safe-Infered |
This module defines the main KURE types: Translate
, Rewrite
and Lens
.
Rewrite
and Lens
are just special cases of Translate
, and so any function that operates on Translate
is also
applicable to Rewrite
and Lens
(although care should be taken in the Lens
case).
This module also contains Translate
instance declarations for the Monad
and Arrow
type-class families.
Given these instances, many of the desirable combinators over Translate
and Rewrite
are special cases
of existing monadic or arrow combinators.
Language.KURE.Combinators provides some additional combinators that aren't in the standard libraries.
- data Translate c m a b = Translate {
- apply :: c -> a -> m b
- type Rewrite c m a = Translate c m a a
- translate :: (c -> a -> m b) -> Translate c m a b
- rewrite :: (c -> a -> m a) -> Rewrite c m a
- contextfreeT :: (a -> m b) -> Translate c m a b
- constT :: m b -> Translate c m a b
- contextT :: Monad m => Translate c m a c
- exposeT :: Monad m => Translate c m a (c, a)
- mapT :: Monad m => Translate c m a b -> Translate c m [a] [b]
- type Lens c m a b = Translate c m a ((c, b), b -> m a)
- lens :: (c -> a -> m ((c, b), b -> m a)) -> Lens c m a b
- idL :: Monad m => Lens c m a a
- tryL :: MonadPlus m => Lens c m a a -> Lens c m a a
- composeL :: Monad m => Lens c m a b -> Lens c m b d -> Lens c m a d
- sequenceL :: MonadPlus m => [Lens c m a a] -> Lens c m a a
- pureL :: Monad m => (a -> b) -> (b -> a) -> Lens c m a b
- focusR :: Monad m => Lens c m a b -> Rewrite c m b -> Rewrite c m a
- focusT :: Monad m => Lens c m a b -> Translate c m b d -> Translate c m a d
Translations
Translate
is a translation or strategy that translates from a value in a context to a monadic value.
Monad m => Arrow (Translate c m) | The |
MonadPlus m => ArrowZero (Translate c m) | The |
MonadPlus m => ArrowPlus (Translate c m) | The |
Monad m => ArrowApply (Translate c m) | The |
Monad m => Category (Translate c m) | The |
Monad m => Monad (Translate c m a) | Lifting through a Reader transformer, where (c,a) is the read-only environment. |
Functor m => Functor (Translate c m a) | Lifting through a Reader transformer, where (c,a) is the read-only environment. |
MonadPlus m => MonadPlus (Translate c m a) | Lifting through a Reader transformer, where (c,a) is the read-only environment. |
Applicative m => Applicative (Translate c m a) | Lifting through a Reader transformer, where (c,a) is the read-only environment. |
Alternative m => Alternative (Translate c m a) | Lifting through a Reader transformer, where (c,a) is the read-only environment. |
(Monad m, Monoid b) => Monoid (Translate c m a b) | Lifting through the |
contextfreeT :: (a -> m b) -> Translate c m a bSource
Build a Translate
that doesn't depend on the context.
Lenses
type Lens c m a b = Translate c m a ((c, b), b -> m a)Source
A Lens
is a way to focus in on a particular point in a structure.
tryL :: MonadPlus m => Lens c m a a -> Lens c m a aSource
Catch a failing endoLens
, making it into an identity.
pureL :: Monad m => (a -> b) -> (b -> a) -> Lens c m a bSource
Construct a Lens
from two pure functions.