Note: if this question is somehow strange, it is because I have only recently been exposed by Haskell, and I am still adapting to functional thinking.
Given a data type, for example Maybe:
data MyOwnMaybe a = MyOwnNothing | MyOwnJust a
everyone using my data type will write functions like
maybeToList :: MyOwnMaybe a -> [a]
maybeToList MyOwnNothing = []
maybeToList (MyOwnJust x) = [x]
Now suppose that at a later time I want to extend this data type
data MyOwnMaybe a = MyOwnNothing | MyOwnJust a | SuperpositionOfNothingAndJust a
How can I make sure that all functions will be broken at compile time?
Of course, there is a chance that somehow I do not "get" algebraic data types, and perhaps I should not do this at all, but given the data type Action
data Action = Reset | Send | Remove
, Action Add ( , Action)