
27 Sep
2011
27 Sep
'11
12:44 p.m.
There's the obvious approach class ConstrName a where constrName :: a -> String instance ConstrName X where constrName A = "A" constrName B{} = "B" constrName C{} = "C" You could automate the instance creating using Template Haskell, to get something like data X = ... deriveConstrName 'X I don't know if there's a more generic way. Cheers, -- Felipe.