[Haskell-beginners] how to make something Typeable, for Data.Dynamic?

Edward Z. Yang ezyang at MIT.EDU
Mon Apr 4 23:22:15 CEST 2011


You need the language extension DeriveDataTypeable,
and then you just add

    deriving (Typeable)

to the end of your data declaration.

Cheers,
Edward

Excerpts from Rob Nikander's message of Mon Apr 04 17:16:57 -0400 2011:
> Hi,
> 
> Can someone show me a code snippet that would make a simple record
> type Typeable so I can wrap one in a Data.Dynamic?  I'm looking at the
> haddock docs and I don't see how to do it.  I know to define "typeOf
> :: MyRecord -> TypeRep".  But how to make a TypeRep?
> 
> thanks,
> Rob
> 



More information about the Beginners mailing list