This project is read-only.

 

type Result<'T> = 
    | Success of 'T
    | Failure 
type MaybeBuilder() = 
    member this.Return x = Success x
    member this.Bind (x:Result<'T>, f: 'T->Result<'u>) = 
        match x with
        | Success(x) -> f x
        | Failure -> Failure
let maybe = MaybeBuilder()
let a = 
    maybe {
        let! b = Success(4);
        let! y = Success true
        return b, y
    }
// the above expression equals the following one:
let r = maybe.Bind(Success 6, fun b -> maybe.Bind(Success true, fun y -> maybe.Return(b, y)))

Last edited Mar 1, 2012 at 8:23 AM by ttliu2000, version 4

Comments

No comments yet.