Skip to content

Instantly share code, notes, and snippets.

@mulambda
Created March 15, 2010 21:27
Show Gist options
  • Save mulambda/333349 to your computer and use it in GitHub Desktop.
Save mulambda/333349 to your computer and use it in GitHub Desktop.
Active pattern for working with Nullable in F#
let (|HasValue|Null|) (x:System.Nullable<_>) =
if x.HasValue then
HasValue (x.Value)
else
Null
let f x =
match x with
| HasValue v -> v + 1
| Null -> 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment