FreeMonadModule

PackageFCQRS.Model
A free monad: a program is a description made of instructions, and an interpreter that the application supplies decides what each instruction does. The same program can run against a database in production and against fixed answers in a test.

Summary

NameSignatureSynopsis
freefree Builds a `Free` program.
freeResultfreeResult Builds a `Free` program that gives a `Result`: a `let!` on an `Error` ends it.
liftFreeliftFree mA program that cannot fail as one that gives a `Result`, so `freeResult` can `let!` it.
liftResultliftResult rA `Result` as a program that performs nothing.

free

free
Member
Builds a `Free` program. A block's code up to its first instruction runs when the block is built, not when the program runs, so a program value shares what that code created between runs: a `let mutable` or a `for` loop's position. Build a program that keeps such state in a function, such as `let order id = free { ... }`, and call it for each run.

Returns

FreeBuilder

freeResult

freeResult
Member
Builds a `Free` program that gives a `Result`: a `let!` on an `Error` ends it. A block's code up to its first instruction runs when the block is built, not when the program runs, so a program value shares what that code created between runs: a `let mutable` or a `for` loop's position. Build a program that keeps such state in a function, such as `let order id = free { ... }`, and call it for each run.

Returns

FreeResultBuilder

liftFree

liftFree m
Member
A program that cannot fail as one that gives a `Result`, so `freeResult` can `let!` it.

Parameters

NameTypeDescription
mFree<'I, 'T>

Returns

Free<'I, Result<'T, 'E>>

liftResult

liftResult r
Member
A `Result` as a program that performs nothing.

Parameters

NameTypeDescription
rResult<'T, 'E>

Returns

Free<'I, Result<'T, 'E>>