Skip to content

Instantly share code, notes, and snippets.

@Wilfred

Wilfred/demo.ml Secret

Created November 20, 2018 16:18
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 Wilfred/f22723e664d4bee69b3a4eba7a2aea0e to your computer and use it in GitHub Desktop.
Save Wilfred/f22723e664d4bee69b3a4eba7a2aea0e to your computer and use it in GitHub Desktop.
matching on constructor of two arguments
type name =
Nickname of string
| FullName of string * string
let match_on_name n =
match n with
Nickname s -> 1, Nickname s
| FullName (x, y) -> 2, FullName (x, y)
let match_on_name2 n =
match n with
Nickname s -> 1, Nickname s
| FullName s -> 2, FullName s (* constructor requires two arguments *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment