-
-
Save Wilfred/ce4b7177f404a482b8fccc0044d15e4c to your computer and use it in GitHub Desktop.
ocaml syntax surprise / type error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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