Copyright | Alej Cabrera 2015 |
---|---|
License | BSD-3 |
Maintainer | cpp.cabrera@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Internal machinery for this effects library. This includes:
- Eff data type, for expressing effects
- NonDetEff data type, for nondeterministic effects
- Functions for facilitating the construction of effects and their handlers
Using http://okmij.org/ftp/Haskell/extensible/Eff1.hs as a starting point.
- data Eff r a
- class Member' t r (FindElem t r) => Member t r where
- type family Members m r :: Constraint
- type Arr r a b = a -> Eff r b
- type Arrs r a b = FTCQueue (Eff r) a b
- data Union r v
- data NonDetEff a where
- makeChoiceA :: Alternative f => Eff (NonDetEff : r) a -> Eff r (f a)
- msplit :: Member NonDetEff r => Eff r a -> Eff r (Maybe (a, Eff r a))
- decomp :: Union (t : r) v -> Either (Union r v) (t v)
- tsingleton :: (a -> m b) -> FTCQueue m a b
- qApp :: Arrs r b w -> b -> Eff r w
- qComp :: Arrs r a b -> (Eff r b -> Eff r' c) -> Arr r' a c
- send :: Member t r => t v -> Eff r v
- run :: Eff `[]` w -> w
- handleRelay :: (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff (t : r) a -> Eff r w
- handleRelayS :: s -> (s -> a -> Eff r w) -> (forall v. s -> t v -> (s -> Arr r v w) -> Eff r w) -> Eff (t : r) a -> Eff r w
- 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
Documentation
The Eff representation.
Status of a coroutine (client): * Val: Done with the value of type a * E : Sending a request of type Union r with the continuation Arrs r b a
type family Members m r :: Constraint Source
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.
A data type for representing nondeterminstic choice
makeChoiceA :: Alternative f => Eff (NonDetEff : r) a -> Eff r (f a) Source
A handler for nondeterminstic effects
tsingleton :: (a -> m b) -> FTCQueue m a b Source
Build a leaf from a single operation [O(1)]
qApp :: Arrs r b w -> b -> Eff r w Source
Function application in the context of an array of effects, Arrs r b w
qComp :: Arrs r a b -> (Eff r b -> Eff r' c) -> Arr r' a c Source
Composition of effectful arrows Allows for the caller to change the effect environment, as well
Runs a set of Effects. Requires that all effects are consumed. Typically composed as follows: > run . runEff1 eff1Arg . runEff2 eff2Arg1 eff2Arg2 (program)
handleRelay :: (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff (t : r) a -> Eff r w Source
Given a request, either handle it or relay it.
handleRelayS :: s -> (s -> a -> Eff r w) -> (forall v. s -> t v -> (s -> Arr r v w) -> Eff r w) -> Eff (t : r) a -> Eff r w Source
Parameterized handleRelay
Allows sending along some state to be handled for the target
effect, or relayed to a handler that can handle the target effect.