I have 2 question regarding writing patterns for constructors:
A simplified example:
datatype X = A | CA | CB | D;
fun foo A = "A"
| foo CA = "A"
| foo CB = "A"
| foo _ = "else";
I would like to write a pattern something like this: A orelse C_ = "A"
(preferably even to find a way to extract the value caught by the underscore).
Any help will be appreciated
SML/NJ supports so called or-patterns:
datatype X = A | CA | CB | D
fun foo (A | CA | CB) = "A"
| foo _ = "else"
That's the most you can do, though. There's no feature to partially match a datatype
constructor name, i.e., your C_
syntax.