free-er-0.1.0.0: An extensible effects library

Contents

Description

Implementation of Eff monad as described by "Freer Monads, More Extensible Effects" by Oleg Kiselyov and Hiromi Ishii.

Synopsis

# Documentation

data Union r v where Source #

r is a type-level list of effect labels and v is type of return value. Union r v is an effectful value that returns v.

Constructors

 UNow :: t v -> Union (t ': r) v UNext :: Union r v -> Union (any ': r) v

decomp :: Union (t ': r) v -> Either (Union r v) (t v) Source #

From a union get a request labelled t or a smaller union without t.

class Member' (FindElem t r) t r => Member t r Source #

Minimal complete definition

inj

Instances

 Member' (FindElem t r) t r => Member t r Source # Methodsinj :: t v -> Union r v

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

Composition of effectful functions. Final function maps a to b and also does effects denoted by r.

data Eff r a Source #

Constructors

 Val a A pure value. Eff (Union r x) (Arrs r x a) An effectful value and continuation.

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 # Methodsfmap :: (a -> b) -> Eff r a -> Eff r b #(<\$) :: a -> Eff r b -> Eff r a # Source # Methodspure :: 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 #

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

Inject an effectful value into an Eff.

kApp :: Arrs r a b -> a -> Eff r b Source #

Apply value a to effectful continuation Arrs r a b.

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

Run an Eff.

runM :: Monad m => Eff '[m] a -> m a Source #

Run Eff in base monad m.

# Continuation queue

data TAQueue f a b where Source #

Constructors

 Leaf :: (a -> f b) -> TAQueue f a b Node :: TAQueue f a x -> TAQueue f x b -> TAQueue f a b

singleton :: (a -> f b) -> TAQueue f a b Source #

snoc :: TAQueue f a x -> (x -> f b) -> TAQueue f a b Source #

append :: TAQueue f a x -> TAQueue f x b -> TAQueue f a b Source #

data ViewL f a b where Source #

Constructors

 Singleton :: (a -> f b) -> ViewL f a b Cons :: (a -> f x) -> TAQueue f x b -> ViewL f a b

viewl :: TAQueue f a b -> ViewL f a b Source #