Skip to content

Instantly share code, notes, and snippets.

@Wilfred

Wilfred/demo.ml Secret

Last active June 29, 2018 20:07
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/ce4b7177f404a482b8fccc0044d15e4c to your computer and use it in GitHub Desktop.
Save Wilfred/ce4b7177f404a482b8fccc0044d15e4c to your computer and use it in GitHub Desktop.
ocaml syntax surprise / type error
type mood = Happy | Sad;;
let foo (m : mood) (b : bool) : int option =
match m with
Happy ->
if true then
None
else
match b with
true -> Some 2
| false -> None
| Sad -> Some 1;;
(* Error: This variant pattern is expected to have type bool
* The constructor Sad does not belong to type bool *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment