[Haskell-cafe] Template Haskell sees into abstract data types
sergueyz at gmail.com
Sat Jul 3 19:10:30 EDT 2010
>> 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.
I cannot write classes that see into internal structure. For example,
I cannot write my own (de)serialization without using from/toAscList.
>> 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.
At least, it looks like I can, I didn't tried, actually.
More information about the Haskell-Cafe