Snippets tagged choice

  • Return the first result using Async.Choice

    The snippet implements Async.Choice method that takes several workflows and creates a workflow, which returns the first result that was computed. After a workflow completes, remaining workflows are cancelled using the F# async cancellation mechanism. (The method doesn't handle exceptions.)

    7 people like this

    Posted: 5 years ago by Tomas Petricek

  • Async.Choice

    A simple extension method for asynchronous non-deterministic computations.

    3 people like this

    Posted: 4 years ago by Nick Palladinos

  • asyncChoose Computational Expression

    A simple computational expression to deal with asynchronous calls that return a choice type to signal failure. Useful for calling remote services that may fail - you can call the remote service with functions of type "request -> Async>" and then chain the results together.

    1 people like this

    Posted: 3 years ago by mavnn

  • Async.Choose operation

    Non-deterministic choice operation for F# asynchronous workflows - creates a workflow that returns the result of one of two asynchronous workflows, depending on which completes first. (The other workflow is not cancelled.)

    4 people like this

    Posted: 5 years ago by Tomas Petricek

  • An implementation of Async.Choice

    This is an implementation of the Async.Choice combinator that composes a sequence of workflows into one whose result is that of the first workflow that returns a *valid* result. You can think of it as a nondeterministic version of (Seq.tryPick id). This implementation draws ideas from Tomas Petricek's choice implementation in UPDATE (11/2015): Following the discussion in I have updated the snippet.

    3 people like this

    Posted: 4 years ago by Eirik Tsarpalis

  • "Guard" helper function for railway error handling

    Defines a "guard" function for railway-style error handing which allows you to concisely verify a condition when handling errors using Choice<'T, 'Error>. It checks the condition and if it is false, returns Choice2Of2 with the specified error value. If the condition is true then it returns Choice1Of2 (). Loosely inspired by Swift 2.0's guard keyword.

    2 people like this

    Posted: 1 years ago by Anton Tcholakov