Second draft: Sum Type by Struct
MaxB
mberger at wolke7.net
Sun Sep 6 16:58:52 UTC 2026
__sumtype Form = int phone | int work; // OK: both are int,
distinguished by name
-----
How to do the match?
Does this work?
f.match {
(phone) => doSomethingWith(phone),
(work) => doSomethingOtherWith(work)
}
Or is it?
f.match {
(phone) => doSomethingWith(f.phone),
(work) => doSomethingOtherWith(f.work)
}
Or must I do this?
f.match {
(int phone) => doSomethingWith(phone),
(int work) => doSomethingOtherWith(work)
}
How do I use a different name instead the tagname? Something like:
f.match {
(phone(p)) => doSomethingWith(p),
(work(w)) => doSomethingOtherWith(w)
}
More information about the dip.development
mailing list