Skip to content

Instantly share code, notes, and snippets.

@xandkar
Created May 2, 2014 15:56
Show Gist options
  • Select an option

  • Save xandkar/39be6f992b992260370b to your computer and use it in GitHub Desktop.

Select an option

Save xandkar/39be6f992b992260370b to your computer and use it in GitHub Desktop.
type 'a list = Nil | Cons of 'a * 'a list;;
type 'a list = Nil | Cons of 'a * 'a list
#
let l = Cons (1, Nil);;
val l : int list = Cons (1, Nil)
#
let hd, tl = match l with Cons (hd, tl) -> hd, tl;;
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Nil
val hd : int = 1
val tl : int list = Nil
#
let hd, tl = match tl with Cons (hd, tl) -> hd, tl;;
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Nil
Exception: "Match_failure //toplevel//:37:13".
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment