If you just wanted the constructor name, show would have worked perfectly.
Data.Typeable with Data.Data worked. Thank you.Using Typeable alone was only giving me the type of the whole type. Data.Data had the toConstr function needed to give me the particular constructor name.For reference if anyone is interested in the solution:import Data.Typeableimport Data.Datadata A = A | B | C deriving (Typeable, Data)typeName :: A -> StringtypeName = show . toConstrI needed to add DeriveDataTypeable extension to my cabal fileOn Sun, Jan 12, 2014 at 2:53 PM, Brandon Allbery <allbery.b@gmail.com> wrote:
--On Sun, Jan 12, 2014 at 9:47 AM, Gareth Morgan <gmorgan1984@gmail.com> wrote:
Won't show include all the components? I wanted to include only the type name.Types only exist at compile time normally. But if you add a Typeable constraint (see Data.Typeable and the DeriveDataTypeable extension) you can get type names at runtime.brandon s allbery kf8nh sine nomine associatesunix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners