A constructor had an argument in a pattern match, but it was defined to have no argument in the datatype
.
datatype d = A | B of int
fun f x =
case x of
A y => y + 1
(** ^^^ unexpected argument for constructor pattern *)
| B z => z - 1
Try one of the following:
-
Remove the argument from the pattern:
datatype d = A | B of int fun f x = case x of A => 1 | B z => z - 1
-
Define the constructor to have an argument:
datatype d = A of int | B of int fun f x = case x of A y => y + 1 | B z => z - 1