Skip to content

Instantly share code, notes, and snippets.

@qxjit
Last active August 29, 2015 13:59
Show Gist options
  • Save qxjit/10497069 to your computer and use it in GitHub Desktop.
Save qxjit/10497069 to your computer and use it in GitHub Desktop.
type A =
| A of int
| B of string
> List.choose (|A|_|) [ A 3; B "foo"];;
List.choose (|A|_|) [ A 3; B "foo"];;
-------------^^^^^
/vagrant/stdin(6,14): error FS0039: The value or constructor '|A|_|' is not defined
let (|IsA|_|) x = match x with | A i -> Some i | _ -> None;;
> List.choose (|IsA|_|) [ A 3; B "foo"];;
val it : int list = [3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment