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.Typeable import Data.Data data A = A | B | C deriving (Typeable, Data) typeName :: A -> String typeName = show . toConstr I needed to add DeriveDataTypeable extension to my cabal file On 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 associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners