[Haskell-cafe] serialize an unknown type

Alberto G. Corona agocorona at gmail.com
Sun Oct 21 20:46:15 CEST 2012


You can include the type in the serialized string. When recovering you can
read the type and use to look for the appropriate deserializer in a lookup
table where you have registered the deserializer.

I use this trick in the IDynamic package,. that serializes-deserializes
dynamic types:

http://hackage.haskell.org/package/IDynamic-0.1


2012/10/20 Corentin Dupont <corentin.dupont at gmail.com>

> Hi the list!
> I have a simple question, how can I serialize/deserialize a structure like
> this:
>
> data InputChoice c  deriving Typeable
> data Event a where
>     InputChoice :: (Eq c, Show c) => [c] -> c -> Event (InputChoice c)
>  (...)
>
> I'd like that the values of type "c" get serialized to a String... That's
> the easy part, but for deserializing, oops!
>
> Cheers,
> Corentin
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


-- 
Alberto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121021/0600a38c/attachment.htm>


More information about the Haskell-Cafe mailing list