Advertisement
Guest User

Untitled

a guest
May 29th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. module Augment =
  2.  
  3. type Microsoft.FSharp.Core.Option<'T> with
  4. static member filter (f : 'T -> bool) (x : option<'T>) =
  5. match x with
  6. | Some v when f(v) -> Some v
  7. | _ -> None
  8.  
  9. static member getOrElse (fallback : 'T) (x : option<'T>) = defaultArg x fallback
  10.  
  11. static member select (f : 'T -> bool) (x : 'T) =
  12. if f(x) then Some x
  13. else None
  14.  
  15. static member nullable (x : 'a when 'a : null) : option<'a> =
  16. if x <> null then Some x
  17. else None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement