Skip to content

Instantly share code, notes, and snippets.

@davidgrenier
Created December 2, 2011 15:45
Show Gist options
  • Select an option

  • Save davidgrenier/1423687 to your computer and use it in GitHub Desktop.

Select an option

Save davidgrenier/1423687 to your computer and use it in GitHub Desktop.
Id&Equals Active patterns
let (|Equals|_|) x y =
if x = y then Some () else None
let (|Id|_|) f x =
if f x then Some () else None
let a = 3;;
match 3 with
| Equals a -> "Yes"
| _ -> "No";;
match seq [1;2;3] with
| Id Seq.isEmpty -> "Empty"
| _ -> "HasSome"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment