|
|
|
|
|
by wellpast
3155 days ago
|
|
This is pretty cool. The Scala version is a little weird. Why do I need a separate Person and Dog class? Can't a dog have a name as well? Why do I need to declare that upfront or ensure that no other part of code can give a Dog a name? That's the problem with ADTs; there's all this impedance. The Elm version is much better. Except of course I have to upfront at the method signature declare my property requirements -- while that is also a burden, it is a much lesser burden than having ADT/taxonomy of Person, Dog, etc. |
|
> Why do I need a separate Person and Dog class?
You don't. It's an example.
> Can't a dog have a name as well?
It can.
> Why do I need to declare that upfront or ensure that no other part of code can give a Dog a name?
I have trouble understanding the meaning of that sentence.