std.effect.alt Implementation of the Alt effect
std.effect.error Implementation of the Error effect
std.effect.lift Implementation of the Lift effect
std.effect.reader Implementation of the Reader effect Implementation of the st.State effect
std.effect.state Implementation of the State effect
std.effect.writer Implementation of the Writer effect

Composable effect types


type Eff r a = 
    | Pure a
    | Impure : forall x . r x -> Arr r x a -> Eff r a

The Eff monad provides composable effect via a Row of effects (r) and produces a value of type a.

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

An effectful function a -> b


let functor : forall r . Functor (Eff r)

A Functor represents an action on a parameterized type which does not change the structure with the mapped type.

The following laws should hold:

  • map id == id
  • map (f << g) == map f << map g

let applicative : forall r . Applicative (Eff r)

A Functor with application.

The following laws should hold:

  • wrap id <*> v = v
  • wrap (<<) <*> u <*> v <*> w = u <*> (v <*> w)
  • wrap f <*> wrap x = wrap (f x)
  • u <*> wrap y = wrap (\g -> g x) <*> u

let monad : forall r . Monad (Eff r)

A generalised interface for imperatively sequencing actions

let run_pure eff : forall a . Eff [| |] a -> a

Extracts the value of type a from an effectful computation. Can only be done once all other effects have been eliminated from the row (leaving [| |] as the empty effect). See each individual effects module on how to eliminate the effect.