Last active
April 12, 2016 17:08
-
-
Save snuxoll/8576568622bba1add260502b35048316 to your computer and use it in GitHub Desktop.
Railway
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
type Result<'TOk,'TError> = | |
| Ok of 'TOk | |
| Error of 'TError | |
let bind fn = | |
function | |
| Ok r -> fn r | |
| Error e -> Error e | |
let (>>=) x fn = | |
bind fn x | |
let test1 x = | |
Ok x | |
let test2 x = | |
if x <> 0 then Ok x else Error x | |
let test3 x = | |
if x <> 1 then Ok x else Error x | |
let result = 0 |> test1 >>= test2 >>= test3 // will never get to test3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment