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 (http://www.actuaries.org.uk/research-and-resources/documents/pma92-pensioners-males-amounts).

    1 people like this

    Posted: 5 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: 2 years ago by cboudereau

  • ResultBuilder Computational Expression

    Computational Expression for Result<'a, 'b>

    3 people like this

    Posted: 4 months 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.

    3 people like this

    Posted: 1 month ago by Aaron Eshbach