[Haskell-cafe] Serialising types with existential data constructors

Misha Aizatulin avatar at hot.ee
Tue Sep 12 08:28:28 EDT 2006

hello all,

  I've been using existentially quantified data constructors like

> 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?

  Has anyone solved the same problem before? I would be very thankful
for any suggestions!

  If Template Haskell would support finding out all instances of a given
class, I could generate a function that would map Names of types to
appropriate Box readers. In the file I would write entries like
<NameOfTypeInTheBox> : <BoxContents>

  But sadly, TH doesn't allow that yet.


More information about the Haskell-Cafe mailing list