
Hi.
Is it possible to discover the data constructor used to make a value without doing pattern matching?
You've already got an answer, but ...
In my current small project I have a data type with a zillion constructors. These use record syntax so that I can access the payload without pattern matching. But I just discovered that it I want to print out the constructor name in my error handling function. Can I do this without, say, hacking around with a string from 'show'?
... to me, it sounds as if instead of: data X = A { x :: Int } | B { x :: Int } | C { x :: Int } you might want: data X = MkX { x :: Int, sort :: Sort } data Sort = A | B | C deriving Show Then you can trivially show the constructor, because it's just a value. Cheers, Andres