[Haskell-cafe] Template Haskell sees into abstract data types

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Sat Jul 3 19:20:25 EDT 2010

Serguey Zefirov <sergueyz at gmail.com> writes:

>>> I cannot directly create my own class instances for them because of
>>> that. But I found that I can write Template Haskell code that could do
>>> that - those data types could be reified just fine.
>> Huh?  Sure you can write class instances for them.
>> ,----
>> | instance SizeOf (Map k v) where
>> |   sizeOf = Map.size
>> `----
> Those are trivial. They are not interesting.

You said you couldn't write any, and of course I wrote a trivial one
because I didn't want to write a whole library in an email.

> I cannot write classes that see into internal structure. For example,
> I cannot write my own (de)serialization without using from/toAscList.

So?  What's wrong with using {from,to}AscList ?

You could also try using GHC's stand-alone deriving mechanism to derive
binary or something:


>>> This is somewhat strange situation.  Was it a design decision?
>> The reason that they are exported abstractly is so that you don't see
>> the internals of the data structure, because 1) you don't need to, and
>> 2) to stop you from doing anything stupid with them.
> I was talking about successful reification of abstract data types.
> That way I can do anything stupid with them.

Why do you want to?

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list