Unless you have a 'real' type for parse sometime during compile time, TH won't be able to generate it. A good rule of thumbs is that if you can't write the code yourself, then you can't get TH to do it either.<div>
<br></div><div>/J<br><div><br></div><div><div class="gmail_quote">On 27 October 2010 08:50, Andy Stewart <span dir="ltr"><<a href="mailto:lazycat.manatee@gmail.com">lazycat.manatee@gmail.com</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">Serguey Zefirov <<a href="mailto:sergueyz@gmail.com">sergueyz@gmail.com</a>> writes:<br>
<br>
> 2010/10/27 Andy Stewart <<a href="mailto:lazycat.manatee@gmail.com">lazycat.manatee@gmail.com</a>>:<br>
>> Hi all,<br>
>><br>
>> I want use TH write some function like below:<br>
>><br>
>> data DataType = StringT<br>
>> | IntT<br>
>> | CharT<br>
>><br>
>> parse :: [(String,DataType)] -> (TypeA, TypeB, ... TypeN)<br>
>><br>
>> Example:<br>
>><br>
>> parse [("string", StringT), ("001", IntT), ("c", CharT)]<br>
>><br>
>> will return:<br>
>><br>
>> ("string", 001, 'c')<br>
>><br>
>> So how to use TH write 'parse' function?<br>
><br>
> I think that you should use TH properly, without compiler and logical errors.<br>
><br>
> What actually do you want?<br>
</div>I'm build multi-processes communication program.<br>
<br>
Example i have two processes : Client and Server.<br>
<br>
At Client side, i pass [DataType] to Server, example:<br>
<br>
[StringT, IntT, CharT]<br>
<br>
Server will handle "user input" with [DataType]<br>
and return result [String] to Client side, example:<br>
<br>
["string", "001", "c"]<br>
<br>
Then at Client side, i need parse [String] to get real value:<br>
<br>
("string", 001, 'c')<br>
<br>
Because, [DataType] have many different case, so i want pass [String]<br>
between processes, and use TH parse result [String] at Client side.<br>
<br>
Thanks,<br>
<font color="#888888"><br>
-- Andy<br>
</font><div><div></div><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br></div></div>