No matching definitions.

tur/free

stdlib/free.tur

Free monad over a functor f for building effect DSLs.

Since: Phase B1

defn

free-pure

(free-pure [x :int])

lift a pure value into the Free monad.

xthe value to lift

A Free value in the pure leaf case.

(free-pure 42)  ; => (PureFree 42)

Since: Phase RF3

defn

free-lift

(free-lift [fx :int])

lift one layer of f into Free.

fxa value of type (f a), where a is the "next step" value

A Free value that suspends on fx.

(free-lift (some 5))

Since: Phase RF3

defn

free-bind

(free-bind [ma :int kont :fn])

monadic bind for Free.

maa Free value
konta typed fat-closure from a to (Free f b), stored as :fn

A new Free value representing the sequenced computation.

(free-bind (free-pure 3) (fn [x] (free-pure (* x 2))))  ; => (PureFree 6)

Since: Phase RF3

defn

free-fmap

(free-fmap [free :int f :fn])

functor map for Free: apply a function to all pure leaves.

freea Free value
fa typed fat-closure from a to b, stored as :fn

A new Free value with f applied to all pure leaves.

Since: Phase RF3

defn

free-run

(free-run [interp :fn free :int])

interpret a Free computation with a natural transformation.

interpa typed fat-closure from (f a) to a, stored as :fn
freea Free computation to run

The result of running free under interp.

(free-run my-interp my-program)

Since: Phase RF3