I was reading about Railway Oriented Programming earlier today, and ended up deciphering a lot of F# code, the following defines a function, that returns another function, the signature is:
bind : ('a -> Result<'b,'c>) -> Result<'a,'c> -> Result<'b,'c>
let bind switchFunction =
fun twoTrackInput ->
match twoTrackInput with
| Success s -> switchFunction s
| Failure f -> Failure f
You can also use the automatically curried version, with two paramaters:
let bind switchFunction twoTrackInput =
match twoTrackInput with
| Success s -> switchFunction s
| Failure f -> Failure f