Safe Haskell | None |
---|---|
Language | Haskell2010 |
Extensions |
|
- data Reader' v e
- data Reader m e o v a
- = ReaderOuter (o m e)
- | ReaderAction (Reader' v e)
- | ReaderResult a
- type ReaderArgT v = v
- type ReaderResT r = r
- effReader :: EffClass Reader' v e => Reader' v r -> Eff e r
- runEffReader :: forall t u m a v m1 e o w a1 r. Monad m => (u t r -> (r -> m (ReaderResT a)) -> m (ReaderResT a)) -> (Reader m1 e o w a1 -> r) -> (r -> Reader t r u v a) -> ReaderArgT v -> Eff r a1 -> m (ReaderResT a)
- ask :: EffClass Reader' v e => Eff e v
- asks :: EffClass Reader' r e => (r -> v) -> Eff e v
Overview
This version builds its output strictly; for a lazy version with the same interface, see Control.THEff.Reader.
{-# LANGUAGE KindSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TemplateHaskell #-} import Control.THEff import Control.THEff.Reader.Strict mkEff "CharReader" ''Reader ''Char ''NoEff mkEff "StrReader" ''Reader ''String ''CharReader main:: IO () main = putStrLn $ runCharReader 'T' $ runStrReader "est" $ do c <- ask s <- ask return $ c:s
Output : "Test"
Types and functions used in mkEff
Actually, the effect type - v - Type - the parameter of the effect. - e - mkEff generated type.
data Reader m e o v a Source #
Type implements link in the chain of effects.
Constructors must be named {EffectName}{Outer|WriterAction|WriterResult}
and have a specified types of fields.
- m - Or Monad (if use the Lift
) or phantom type - stub (if used NoEff
).
- o - Type of outer effect.
- a - The result of mkEff generated runEEEE... function.
ReaderOuter (o m e) | |
ReaderAction (Reader' v e) | |
ReaderResult a |
type ReaderArgT v = v Source #
Type of fourth argument of runEffReader and first argument of runEEEE.
type ReaderResT r = r Source #
Result type of runEEEE.
effReader :: EffClass Reader' v e => Reader' v r -> Eff e r Source #
This function is used in the mkEff
generated runEEEE functions and typically
in effect action functions. Calling the effect action.
:: forall (t :: * -> *) (u :: (* -> *) -> * -> *) (m :: * -> *) (m1 :: * -> *) (o :: (* -> *) -> * -> *). Monad m | |
=> (u t r -> (r -> m (ReaderResT a)) -> m (ReaderResT a)) | The outer effect function |
-> (Reader m1 e o w a1 -> r) | The chain of effects link wrapper. |
-> (r -> Reader t r u v a) | The chain of effects link unwrapper. |
-> ReaderArgT v | The initial value of argument of effect. |
-> Eff r a1 | |
-> m (ReaderResT a) |
The main function of the effect implementing.
This function is used in the mkEff
generated runEEEE functions.