Snippets tagged computation expression

  • Joint Life Annuity

    This Joint Life Annuity calculation relies on the objects and functions defined in Single Life Annuity. A joint life annuity calculates the present value of an annuity from current age to death of a member and another life (spouse). The implementation below uses the AgeVectorBuilder from the Single Life Annuity snippet in two examples: The first defines a simple Joint Life Annuity that assumes no age difference between the two lives. The second assumes an N year age difference. The samples both rely on a male mortality table (PMA92 (C=2003)) and a female mortality table (PFA92 (C=2003)) which are extracts of publicly available mortality tables (

    1 people like this

    Posted: 11 years ago by Kevin Roche

  • Async task computation expression

    Async task computation expression, in order to avoid Async.AwaitTask for C# interop

    3 people like this

    Posted: 8 years ago by cboudereau

  • ResultBuilder Computational Expression

    Computational Expression for Result<'a, 'b>

    8 people like this

    Posted: 6 years ago by Yuriy Habarov

  • Await Computation Expression (Task + Async Interoperability)

    When writing asynchronous code in F#, one often needs to call methods in the .NET BCL that return Task or Task rather than the F# native Async<'a> type. While the Async.AwaitTask function can convert a Task into an Async<'a>, there is some cognitive overhead in having to keep track of which functions return Task and which functions are Async. To simplify this interoperability, this code provides new `await` computation expression that supports using both Async<'a> and Task or Task inside it. This works by unifying the Task and Async types in the Awaitable DU, and overloading the Bind, ReturnFrom, Combine, and Using methods on the AwaitableBuilder Computation Builder to handle Awaitable<'a>, Async<'a>, Task, and Task.

    5 people like this

    Posted: 5 years ago by Aaron Eshbach

  • Computation expression over StringBuilder

    A computation expression builder which simplify StringBuilder usage.

    5 people like this

    Posted: 4 years ago by Sehnsucht

  • Capture the rest of sequence on error

    Computation expression that automatically captures the rest of the sequence that you are iterating over using a "for" loop so that the exception handler can do something clever with it.

    0 people like this

    Posted: 2 years ago by Tomas Petricek

  • An IAsyncEnumerable computation expression (complete)

    (Please ignore previous entry of the same name)

    0 people like this

    Posted: 2 years ago by Julien Di Lenarda