I am attempting to get to grips with Railway Oriented Programming using Chessie.
I have several API libraries written in C# whichI am shimming to provide a safer interface - rather than Task I would like to provide Async<Result<foo,_>.
With this in mind, I am struggling to see how I get an Async or Async<Result<foo,>> into an AsyncResult<foo,>>
I am new to the language, and assume I am missing something.
I ended up with
// normal async code here.
A very late reply, but just in case someone else stumbles across this:
let main argv =
let maybeFoo (aBool: bool) =
then return ok (true,["it was true"])
else return fail "failed"
let resultFoo : AsyncResult<_,_> =
AR (maybeFoo true)
It’s a single case discriminated union, so it just needs wrapping. The source:
/// Represents the result of an async computation
type AsyncResult<'a, 'b> =
| AR of Async<Result<'a, 'b>>