mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Redundancy is not permitted in pattern matching
This commit is contained in:
parent
6e7c5c7933
commit
add335bd0b
@ -351,7 +351,10 @@ val _ = print (say(Red) ^ "\n")
|
||||
fun say Red = "You are red!"
|
||||
| say Green = "You are green!"
|
||||
| say Blue = "You are blue!"
|
||||
| say _ = raise Fail "Unknown color"
|
||||
|
||||
(* We did not include the match arm `say _ = raise Fail "Unknown color"`
|
||||
because after specifying all three colors, the pattern is exhaustive
|
||||
and redundancy is not permitted in pattern matching *)
|
||||
|
||||
|
||||
(* Here is a binary tree datatype *)
|
||||
|
Loading…
Reference in New Issue
Block a user