Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype Language effects a = Language {
- getLanguage :: FreeF (LanguageF effects) a (Language effects a)
- newtype LanguageF effects a = LanguageF {
- getLanguageF :: CoRec (Apply a) effects
- liftE :: (effect ∈ effects, Functor effect) => effect a -> LanguageF effects a
- class Monad m => MonadLanguage m effects | m -> effects where
- fromUnitLanguageF :: forall f a. LanguageF `[f]` a -> f a
- fromLanguage :: Language effects a -> Free (LanguageF effects) a
- iterL :: (LanguageF effects a -> a) -> Language effects a -> a
- iterLM :: Monad m => (LanguageF effects (m a) -> m a) -> Language effects a -> m a
Documentation
newtype Language effects a Source
a domain-specific language
that supports the effects
.
e.g.
Language [f,g] a
Language | |
|
Monad (Language effects) Source | |
Functor (Language effects) Source | |
Applicative (Language effects) Source | |
MonadLanguage (Language effects) effects Source | The simplest concrete implementation for the interface. Analogous to liftL = |
MonadFree (LanguageF effects) (Language effects) Source |
newtype LanguageF effects a Source
a (type-level) sum
of "language features".
Generally, a (1) lifted, (2) n-ary, (3) associative sum.
the expression
may use any effect in effects
:
expression :: LanguageF effects
generalizes Either
:
LanguageF '[f,g] a ~ Either (f a) (g a)
LanguageF | |
|
class Monad m => MonadLanguage m effects | m -> effects where Source
the m
onad supports each effect
a "final encoding" (TODO, is it?) for injecting functors into a sum.
Analogous to liftF
.
e.g.
data ClipboardF k = GetClipboard (String -> k) | SetClipboard String k getClipboard :: (MonadClipboard m effects) => m String getClipboard = liftL $ GetClipboard id -- GetClipboard id :: ClipboardF String setClipboard :: (MonadClipboard m effects) => String -> m ()) setClipboard s = liftL $ SetClipboard s () -- SetClipboard s () :: ClipboardF () type MonadClipboard m effects = (MonadLanguage m effects, ClipboardF ∈ effects)
the FunctionalDependency
(i.e. m -> effects
) says:
"a language-monad supports one set of effects".
MonadLanguage (Language effects) effects Source | The simplest concrete implementation for the interface. Analogous to liftL = |
Monoid w => MonadLanguage (RWS r w s) ((:) (* -> *) (ReaderF r) ((:) (* -> *) (WriterF w) ((:) (* -> *) (StateF s) ([] (* -> *))))) Source |
fromUnitLanguageF :: forall f a. LanguageF `[f]` a -> f a Source
fromLanguage :: Language effects a -> Free (LanguageF effects) a Source
cast a (newtype
'd) Language
to Free
. TODO is cheap (can use coerce
)?