It isn't an exception; it is a type error saying that you can't use cons constructor ::
belonging to 'a list
with 'a set
.
Assuming that you have two constructors Nilset
and Set
in a recursive datatype:
datatype 'a set = Nilset | Set of 'a * 'a set
You should follow the recursive structure of your datatype to define isMember
:
fun isMember (k, Set(x, xs)) = k = x orelse isMember (k, xs)
| isMember (k, Nilset) = false
Certainly, for serious use of Set
, you should look into Set structure.