Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Created October 11, 2018 10:42
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 isaacabraham/0b28ded9a75bcf4f20db11aedec219eb to your computer and use it in GitHub Desktop.
Save isaacabraham/0b28ded9a75bcf4f20db11aedec219eb to your computer and use it in GitHub Desktop.
type Person = { IsClever : bool }
let p = { IsClever = true }
/// Warning - missed "false"
let example1 =
match p with
| { IsClever = true } -> "Yes, this person is clever"
/// No warning - all cases matched
let example2 =
match p with
| { IsClever = true } -> "Yes, this person is clever"
| { IsClever = false } -> "Fully matched!"
/// Warning - even though all cases are "theoretically" matched
let example3 =
let number = 10
match p with
| { IsClever = true } -> "Yes, this person is clever"
| { IsClever = false } when number > 10 -> "Clever when number is more than 10"
| { IsClever = false } when number <= 10 -> "Clever when number is not more than 10"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment