[Haskell-cafe] Serialising types with existential data constructors

Einar Karttunen ekarttun at cs.helsinki.fi
Wed Sep 13 02:29:07 EDT 2006


On 12.09 15:28, Misha Aizatulin wrote:
>   I've been using existentially quantified data constructors like
> 
> > data Box = forall a. Cxt a => Box a

If you can include Typeable into the mix then serializing works.

Serialize the value as "<name of type> <value>".

When deserializing use a Map <name of type> <decoder-function>
and get the appropriate decoder from there for the type in question.

- Einar Karttunen


More information about the Haskell-Cafe mailing list