Before answering, I must point out that you might fall into the general misconception of beginners about ADT. Remember that Haskell has two separate namespaces for type and term levels. Therefore, if we write:
data A = Foo data B = Bar data C = Baz data D = A | B | C
... then there is no connection between type A and constructor A type D Therefore, I suspect (but not quite sure!) That the question you wanted to ask had the following format for type D , but instead:
data D = AA | BB | CC
In this case, the short answer is no. You might wish you could attack deriving Dog or something similar and do it, but this object is not provided by the language. However, there are a few packages for general programming that can help: just check the list of Hackage packages and find the βderivativeβ, and you'll get about ten hits.
source share