Skip to content

Instantly share code, notes, and snippets.

@ashtonkj

ashtonkj/Maybe.fs

Created Jul 29, 2014
Embed
What would you like to do?
Maybe
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
You can’t perform that action at this time.