Skip to content

Instantly share code, notes, and snippets.

@ashtonkj
Created July 29, 2014 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashtonkj/96f862b4c49a6eab9c31 to your computer and use it in GitHub Desktop.
Save ashtonkj/96f862b4c49a6eab9c31 to your computer and use it in GitHub Desktop.
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