[Haskell-beginners] How to print the name of a variable
stephen.tetley at gmail.com
Sat Mar 20 07:03:35 EDT 2010
Doesn't that associate names with types rather than names with values though:
instance HasName Int where
name = "Int"
> printWithName (1::Int)
> printWithName (70::Int)
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
type Named a = (String,a)
More information about the Beginners