Last active
January 23, 2019 01:54
-
-
Save dam5s/392851fdc1a905af5191d48978bd856a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[<AutoOpen>] | |
module Prelude | |
type AsyncResult<'T, 'TError> = | |
Async<Result<'T, 'TError>> | |
module AsyncResult = | |
let map (mapping : 'T -> 'U) (result : AsyncResult<'T, 'TError>) : AsyncResult<'U, 'TError> = | |
async { | |
match! result with | |
| Ok value -> return Ok (mapping value) | |
| Error err -> return Error err | |
} | |
let bind (mapping : 'T -> AsyncResult<'U, 'TError>) (result : AsyncResult<'T, 'TError>) : AsyncResult<'U, 'TError> = | |
async { | |
match! result with | |
| Ok value -> return! mapping value | |
| Error err -> return Error err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment