Closed games closed 6 years ago
I think you can write your own pretty easily without getting into the guts of task handling, just by wrapping TaskBuilder
. For now, I recommend going that route.
e.g.
type TaskResultBuilder() =
member this.Bind
( resultTask : Result<'ok, 'err> Task
, onOk : 'ok -> Task<Result<'out, 'err>>
) : Task<'out, 'err>> =
task {
let! maybe = resultTask
match maybe with
| Ok yep -> return! onOk yep
| Error e -> return Error e
}
member this.Return(x) = Task.FromResult(Ok x)
Hi @rspeele, yes I can write my own TaskResultBuilder (I currently do it in my few projects) but just I need to copy the file to all of my projects which uses Task+Result. so just wondering if I can use any other thirth party lib instead I do myself (especially I am using your TaskBuilder) :-)
I recommend publishing your own wrapper (that you mentioned you're currently using) as a NuGet package. If you don't want it to be a big thing, you can use a local feed.
Hi, do you plan or any idea to make a TaskResultBuilder which similar with AsyncChoiceBuilder.