3 ms·
As is often the case, writing the code from scratch in Haskell is easier than reusing a library in Java.. Android uses named integers rather than enums, due to
by Peaker 13y ago
As is often the case, writing the code from scratch in Haskell is easier than reusing a library in Java..
Android uses named integers rather than enums, due to some issue with Java enums.. And the switch would only help a bit, the main problem is needing to correctly interpret the associated payload according to the message type. That's what sum types give you, which Java doesn't properly have.
They could be emulated with visitor pattern, if one is masochistic...
- sixbrx 13y agoI never understood why Java didn't go to proper sum types when it introduced enums. They all have to have the same shape, just distinguished by their method implementations, same as always in OO. What kind mechanism for describing alternatives is that?