FreeModule
PackageFCQRS.Model
Functions that build, combine, and run programs.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| bind | bind next program | `program`, then `next` applied to its result. |
| return' | return' x | A program that performs nothing and gives `x`. |
| map | map f m | `m`, with `f` applied to its result. |
| tryWith | tryWith body handler | Runs `body`, and gives an exception that the program's own code throws to `handler`. |
| tryFinally | tryFinally body compensation | Runs `body`, then `compensation` once: when the program finishes, or when its own code throws. |
| whileLoop | whileLoop guard body | Runs `body` while `guard` holds. |
| run | run handle program | Runs a program with an interpreter that answers each instruction at once. |
| runAsync | runAsync handle program | Runs a program with an interpreter that answers each instruction asynchronously. |
| runTask | runTask handle program | Runs a program with an interpreter that answers each instruction with a task. |
`program`, then `next` applied to its result.
Parameters
| Name | Type | Description |
|---|---|---|
| next | 'A -> Free<'I, 'B> | |
| program | Free<'I, 'A> |
Returns
Free<'I, 'B>
A program that performs nothing and gives `x`.
Parameters
| Name | Type | Description |
|---|---|---|
| x | 'a |
Returns
Free<'b, 'a>
`m`, with `f` applied to its result.
Parameters
| Name | Type | Description |
|---|---|---|
| f | 'a -> 'b | |
| m | Free<'c, 'a> |
Returns
Free<'c, 'b>
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
| Name | Type | Description |
|---|---|---|
| body | unit -> Free<'I, 'A> | |
| handler | exn -> Free<'I, 'A> |
Returns
Free<'I, 'A>
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
| Name | Type | Description |
|---|---|---|
| body | unit -> Free<'I, 'A> | |
| compensation | unit -> unit |
Returns
Free<'I, 'A>
Runs `body` while `guard` holds. Rounds that perform no instruction run in a loop.
Parameters
| Name | Type | Description |
|---|---|---|
| guard | unit -> bool | |
| body | unit -> Free<'I, unit> |
Returns
Free<'I, unit>
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
| Name | Type | Description |
|---|---|---|
| handle | 'I -> obj | |
| program | Free<'I, 'R> |
Returns
'R
Runs a program with an interpreter that answers each instruction asynchronously.
Parameters
| Name | Type | Description |
|---|---|---|
| handle | 'I -> Async<obj> | |
| program | Free<'I, 'R> |
Returns
Async<'R>