[Haskell-cafe] Serialising types with existential data constructors

Misha Aizatulin avatar at hot.ee
Tue Sep 12 10:15:33 EDT 2006


Bulat Ziganshin wrote:

>> data Box = forall a. Cxt a => Box a
>>   quite successfully for a while. But now I am trying to implement the
>> Load/Save mechanism and getting stuck with that. It's not hard to write
>> a Box into a file, but how do I get it back?
> 
> gshow/gread provided by module Data.Generics.Text

  I am afraid this won't do it. For gread to work I still need to know
the result type before I call it, but the problem with the Box is
exactly that you don't know the type it will contain in advance.

  Maybe there is a way to dump the binary representation of the whole
box and then read it back (using unsafeCoerce or similar stuff on the way)?

Cheers,
  Misha


More information about the Haskell-Cafe mailing list