
20 Mar
2010
20 Mar
'10
7:03 a.m.
Hi Ozgur Doesn't that associate names with types rather than names with values though: instance HasName Int where name = "Int"
printWithName (1::Int) Int: 1
printWithName (70::Int) Int: 70
I think the same is achievable with Data.Typeable / Data.Data although how to do it is somewhat buried... For associating names and values you'd still need to do it 'by hand' with something like data Named a = Named String a deriving (Show) or type Named a = (String,a) Best wishes Stephen