|
|
|
|
|
by ollysb
1037 days ago
|
|
This is definitely an FP vs OO thing. If you wanted to refer to the value in an ADT you'd introduce a new type to refer to it, which in Elm would be: type Message
= IncrementBy Amount
| DecrementBy Amount
| Set Amount
type Amount = Amount Int
Obviously this is a contrived example - you wouldn't bother if you were dealing with an Int but once the message gets more complicated it can make sense. |
|
Given the above ADT, how would you write a function that prints the amount of a Message, regardless of which case it is?