Hi Iustin,<br>yes I want to deserialize an unknown type based on the content of the file (in this example).<br>Let's say I can reduce the spectum of types to: Strings, all the types in Enum, Ints. Is it possible?<br><br>
My real problem is that on my web interface I want to use web routes to allow a user to pass an Event back to the engine.<br>The problem is that it seems that web-routes only accepts Strings (or some known types) to be passed on the web route, whereas I need to pass random types.<br>
<br><br><div class="gmail_quote">On Sun, Oct 21, 2012 at 8:00 PM, Iustin Pop <span dir="ltr"><<a href="mailto:iusty@k1024.org" target="_blank">iusty@k1024.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sun, Oct 21, 2012 at 07:20:10PM +0200, Corentin Dupont wrote:<br>
> Hi,<br>
> Sorry if it was not enough explicit.<br>
> I want to write functions like this:<br>
><br>
> serialize :: (Show a) => Event a -> IO ()<br>
> deserialize :: (Read a) => IO () -> Event a<br>
><br>
> The functions would write and read the data in a file, storing/retrieving<br>
> also the type "a" I suppose...<br>
<br>
</div>Can't you simply, when defining the type event, add a "deriving (Show,<br>
Read)"? Then the standard (but slow) read/show serialisation would work<br>
for you.<br>
<br>
If you're asking to de-serialise an unknown type (i.e. you don't know<br>
what type it should restore a-priori, but you want to do that based on<br>
the contents of the file), things become a little more complex. Unless<br>
you can further restrict the type 'a', really complex.<br>
<br>
Maybe stating your actual problem, rather than the implementation<br>
question, would be better?<br>
<br>
regards,<br>
iustin<br>
</blockquote></div><br>