Navigation

Kernel

Freer monad kernel: Return/OpCall ADT with FTCQueue bind, send, map, seq, pipe, kleisli.

bind

bind: sequence two computations; if the first is Pure, apply f to its value; otherwise snoc f onto the FTCQueue for O(1) per-step composition.

bind : Computation a -> (a -> Computation b) -> Computation b

Monadic bind:

bind comp f = case comp of
  Pure a     -> f a
  Impure e q -> Impure e (snoc q f)

O(1) per bind via FTCQueue snoc (Kiselyov & Ishii 2015, section 3.1).

impure

impure: re-export of fx.comp.impure for kernel consumers.

impure : Effect -> FTCQueue -> Computation a

Re-export of the computation Impure constructor.

kleisli

kleisli: compose two Kleisli arrows (a -> M b) and (b -> M c) into a single (a -> M c); the arrow product of the freer-monad Kleisli category.

kleisli : (a -> Computation b) -> (b -> Computation c) -> a -> Computation c

Kleisli composition. Compose two Kleisli arrows into a single arrow. The associative >=> operator in Haskell terminology.

map

mapComp (exported as map): apply f to the eventual result of a computation (Functor instance); implemented as bind comp (x: pure (f x)).

map : (a -> b) -> Computation a -> Computation b

Map a function over the result of a computation (Functor instance). Exposed as map at the module's top-level.

pipe

pipe: chain a computation through a list of Kleisli arrows, threading each result into the next via bind; the empty arrow list yields init unchanged.

pipe : Computation a -> [(a -> Computation b)] -> Computation b

Chain a computation through a list of Kleisli arrows. Each arrow's input is the previous arrow's output.

pure

pure: re-export of fx.comp.pure for kernel consumers.

pure : a -> Computation a

Re-export of the computation Pure constructor.

queue

queue: re-export of the FTCQueue namespace for advanced handler composition and adaptation.

queue : Namespace

Re-export of fx.queue for advanced use.

send

send: lift an effect request named name carrying param into a computation suspended at that effect; the handler's response resumes via the continuation queue.

send : String -> a -> Computation b

Send an effect request. Returns an Impure computation whose continuation queue resolves to the handler's response.

seq

seq: thread a list of computations left-to-right via bind, discarding intermediate values and returning only the last; the empty list yields pure null.

seq : [Computation a] -> Computation a

Sequence a list of computations, threading effects via bind. Returns the last result; intermediate values are discarded.