Created
July 29, 2014 19:27
-
-
Save ashtonkj/96f862b4c49a6eab9c31 to your computer and use it in GitHub Desktop.
Maybe
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 MaybeBuilder() = | |
member this.Bind(m,f) = Option.bind f m | |
member this.Return(m) = Some(m) | |
let maybe = MaybeBuilder() | |
// Returns Some (querystring) or None if the let! returns None. | |
let queryString = | |
maybe { | |
let! val = x.Query | |
return val | |
|> Seq.map (fun (k,v) -> k + "=" + v) | |
|> String.concat "&" | |
|> (+) "?"` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment