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.<div><br></div><div>I use this trick in the IDynamic package,. that serializes-deserializes dynamic types:</div>

<div><br></div><div><a href="http://hackage.haskell.org/package/IDynamic-0.1">http://hackage.haskell.org/package/IDynamic-0.1</a></div><div><br></div><div><br><div class="gmail_quote">2012/10/20 Corentin Dupont <span dir="ltr">&lt;<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi the list!<br>I have a simple question, how can I serialize/deserialize a structure like this:<br><br>data InputChoice c  deriving Typeable<br>

data Event a where<br>    InputChoice :: (Eq c, Show c) =&gt; [c] -&gt; c -&gt; Event (InputChoice c)<br>
 (...)<br><br>I&#39;d like that the values of type &quot;c&quot; get serialized to a String... That&#39;s the easy part, but for deserializing, oops!<br><br>Cheers,<br>Corentin<br>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Alberto.<br>
</div>