Reputation: 869
I would like to write a SelectMany monadic bind from a Task in F#. How would I write the following C# code which uses language-ext in F#?
Task<int> result = from task in Task.Run<int>(() => 40) select task + 2;
Upvotes: 3
Views: 152
Reputation: 243051
You can use the F# TaskBuilder library to get the F# computation expression (monadic syntax) for tasks. With this, you can rewrite your example as:
let result = task {
let! t = Task.Run<int>(() => 40)
return t + 2 }
Upvotes: 4