FreeModule

PackageFCQRS.Model
Functions that build, combine, and run programs.

Summary

NameSignatureSynopsis
bindbind next program`program`, then `next` applied to its result.
return'return' xA program that performs nothing and gives `x`.
mapmap f m`m`, with `f` applied to its result.
tryWithtryWith body handlerRuns `body`, and gives an exception that the program's own code throws to `handler`.
tryFinallytryFinally body compensationRuns `body`, then `compensation` once: when the program finishes, or when its own code throws.
whileLoopwhileLoop guard bodyRuns `body` while `guard` holds.
runrun handle programRuns a program with an interpreter that answers each instruction at once.
runAsyncrunAsync handle programRuns a program with an interpreter that answers each instruction asynchronously.
runTaskrunTask handle programRuns a program with an interpreter that answers each instruction with a task.

bind

bind next program
Member
`program`, then `next` applied to its result.

Parameters

NameTypeDescription
next'A -> Free<'I, 'B>
programFree<'I, 'A>

Returns

Free<'I, 'B>

return'

return' x
Member
A program that performs nothing and gives `x`.

Parameters

NameTypeDescription
x'a

Returns

Free<'b, 'a>

map

map f m
Member
`m`, with `f` applied to its result.

Parameters

NameTypeDescription
f'a -> 'b
mFree<'c, 'a>

Returns

Free<'c, 'b>

tryWith

tryWith body handler
Member
Runs `body`, and gives an exception that the program's own code throws to `handler`. It sees exceptions from the code between instructions. What an interpreter does when it cannot carry out an instruction is the interpreter's choice.

Parameters

NameTypeDescription
bodyunit -> Free<'I, 'A>
handlerexn -> Free<'I, 'A>

Returns

Free<'I, 'A>

tryFinally

tryFinally body compensation
Member
Runs `body`, then `compensation` once: when the program finishes, or when its own code throws. A program that an interpreter abandons at an instruction never runs it.

Parameters

NameTypeDescription
bodyunit -> Free<'I, 'A>
compensationunit -> unit

Returns

Free<'I, 'A>

whileLoop

whileLoop guard body
Member
Runs `body` while `guard` holds. Rounds that perform no instruction run in a loop.

Parameters

NameTypeDescription
guardunit -> bool
bodyunit -> Free<'I, unit>

Returns

Free<'I, unit>

run

run handle program
Member
Runs a program with an interpreter that answers each instruction at once. The answer is boxed, and must have the type the instruction's caller expects.

Parameters

NameTypeDescription
handle'I -> obj
programFree<'I, 'R>

Returns

'R

runAsync

runAsync handle program
Member
Runs a program with an interpreter that answers each instruction asynchronously.

Parameters

NameTypeDescription
handle'I -> Async<obj>
programFree<'I, 'R>

Returns

Async<'R>

runTask

runTask handle program
Member
Runs a program with an interpreter that answers each instruction with a task.

Parameters

NameTypeDescription
handle'I -> Task<obj>
programFree<'I, 'R>

Returns

Task<'R>