Logo Orsak

Builder Module

The eff computation expression, and mkEffect.

Functions and values

Function or value Description

eff

Full Usage: eff

Returns: EffBuilder

The computation expression for writing effects. Binding (let!, do!, return!) works with other effects, and with Task, ValueTask, Async and Result, so .NET APIs can be used directly. It supports for, while, use, try/with and try/finally, and and! runs effects concurrently. A failed effect stops the rest of the expression, with its error.

Returns: EffBuilder
Example

 let placeOrder (order: Order) = eff {
     let! id = GuidGenerator.genGuid ()
     let! now = Time.utcNow ()
     do! Orders.save { order with Id = id; Placed = now }
     let! customer = Customers.load order.CustomerId
     and! stock = Stock.reserve order.Lines
     return id
 }
val placeOrder: order: 'a -> 'b
val order: 'a
val id: x: 'T -> 'T

mkEffect d

Full Usage: mkEffect d

Parameters:
    d : 'a -> AsyncResult<'b, 'c> - The function that starts the effect.

Returns: Effect<'a, 'b, 'c>
Modifiers: inline
Type parameters: 'a, 'b, 'c

Creates an effect from a function that, given an environment, starts it. Prefer Effect.Create or the eff computation expression; this is the lowest-level way to create an effect.

d : 'a -> AsyncResult<'b, 'c>

The function that starts the effect.

Returns: Effect<'a, 'b, 'c>

Type something to start searching.