Saying “Haskell has this feature and it allows you to express some common Haskell patterns more succinctly” does not imply “Adding this feature to PHP will allow you to do the same”. Haskell is a very different language, targeting a very different audience.
Do you have an example of a common pattern in PHP that can be made simpler by case-specific methods? I haven’t, yet.
Explanation:
Recent ENUM proposal had option of declaring per case functions in enum definition. When I first read about it, I had no actual experience with how such functionality would be used. Then proposal changed to leave that functionality out. Again, since I had no experience I could not evaluate how much would be missed.
Only once I read above article did I realized how powerful concept it can actually be.
Short summary:
Article introduces CSV type defined as Abstract Data Type, and shows how letting CSV be either named (as in columns are named by “header” row) or numbered (as in 2nd column is indexed by number 2), is not sufficiently ergonomic.
Named CSV can support more functionality, but ADT require pattern matching, and that will result in needless pattern match branches for “impossible” combinations.
Allowing per case functionality, and letting type checker track cases separately, and let developers ommit “impossible” combinations, as type checker will catch those.
Which begs the question. Can current RFC implementation allow such mechanism in the future?
(*)If from description “Inheritance” seams obvious solution, please reconsider. ADTs capture notion of multiple UNRELATED things still being one overall type. Inheritance (that respect Lipskov substitution principle), is only about types that can be used instead of others, thus they imply very strong coupling between things. More appropriate approximation would be to define interface for cases. ADT version would be somewhat equivalent to a single interface, with a need for numbered CSV to throw “unimplemented” exceptions. While GADT version would be equivalent to separate interfaces with type checker being able to understand when those two are equivalent and when they are not.