Einar Karttunen 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.
This is indeed the only solution I see so far. It has a serious problem though: as soon as I write the mapping, I limit once and for all the set of all types that can be used with my box. And I do so in a non-extensible way - if someone later would like to use my box with some other type in it, they wouldn't be able to. In fact, I start wondering, how OO languages solve the same problem. I'll take a look at Java now. Cheers, Misha _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe