4 ms·
Okay, so it's union types plus pattern matching that are missing (among other things I'm sure). Thanks, that's helpful. > You cannot safely "match" on the comm
by jgwil2 6y ago
Okay, so it's union types plus pattern matching that are missing (among other things I'm sure). Thanks, that's helpful.
> You cannot safely "match" on the command in the same way you can in other languages, because the compiler doesn't know that there are only exactly 3 types of commands.
Perhaps the visitor pattern? Command processing receives an object and calls its command method, which knows what permissions it has.
I guess the fact that I have to keep saying "patterns" is a hint that some flexibility is missing. Still, I'd rather have Java/C++ static types than nothing at all.
- dwohnitmok 6y agoYes the visitor pattern is a valid encoding of algebraic datatypes. Very heavyweight (imagine if booleans were all encoded with the visitor pattern) but nonetheless valid. https://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/ https://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/