more-extensible-effects-0.1.0.4: Initial project template from stack

Safe HaskellNone
LanguageHaskell2010

Control.Monad.Eff.Internal

Synopsis

Documentation

type Arr r a b = a -> Eff r b Source #

Effectful arrow type: a function from a to b that also does effects denoted by r

type Arrs r a b = FTCQueue (Eff r) a b Source #

An effectful function from a to b that is a composition of several effectful functions. The paremeter r describes the overall effect. The composition members are accumulated in a type-aligned queue

data Eff r a where Source #

The Eff monad (not a transformer!) It is a fairly standard coroutine monad It is NOT a Free monad! There are no Functor constraints Status of a coroutine (client): done with the value of type w, or sending a request of type Union r with the continuation Arrs r b a. Potentially, inline Union into Impure

Constructors

Pure :: a -> Eff r a 
Impure :: Union r x -> Arrs r x a -> Eff r a 

Instances

Monad (Eff r) Source # 

Methods

(>>=) :: Eff r a -> (a -> Eff r b) -> Eff r b #

(>>) :: Eff r a -> Eff r b -> Eff r b #

return :: a -> Eff r a #

fail :: String -> Eff r a #

Functor (Eff r) Source # 

Methods

fmap :: (a -> b) -> Eff r a -> Eff r b #

(<$) :: a -> Eff r b -> Eff r a #

Applicative (Eff r) Source # 

Methods

pure :: a -> Eff r a #

(<*>) :: Eff r (a -> b) -> Eff r a -> Eff r b #

(*>) :: Eff r a -> Eff r b -> Eff r b #

(<*) :: Eff r a -> Eff r b -> Eff r a #

qApp :: Arrs r b w -> b -> Eff r w Source #

Application to the `generalized effectful function' Arrs r b w

qComp :: Arrs r a b -> (Eff r b -> Eff r' c) -> Arr r' a c Source #

Compose effectful arrows (and possibly change the effect!)

qComps :: Arrs r a b -> (Eff r b -> Eff r' c) -> Arrs r' a c Source #

send :: Member t r => t v -> Eff r v Source #

send a request and wait for a reply

run :: Eff '[] w -> w Source #

type Handler t r w = forall v. t v -> Arr r v w -> Eff r w Source #

Handler type

type HandlerS s t r w = forall v. s -> t v -> (s -> Arr r v w) -> Eff r w Source #

Parameterized Handler type

handleRelay :: (a -> Eff r w) -> Handler t r w -> Eff (t ': r) a -> Eff r w Source #

A convenient pattern: given a request (open union), either handle it or relay it.

handleRelayS :: s -> (s -> a -> Eff r w) -> HandlerS s t r w -> Eff (t ': r) a -> Eff r w Source #

Parameterized handleRelay

interpose :: Member t r => (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff r a -> Eff r w Source #

Intercept the request and possibly reply to it, but leave it unhandled (that's why we use the same r all throuout)