[Haskell-cafe] Help me TH code.

Jonas Almström Duregård jonas.duregard at chalmers.se
Wed Oct 27 04:38:48 EDT 2010


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.

/J

On 27 October 2010 08:50, Andy Stewart <lazycat.manatee at gmail.com> wrote:

> Serguey Zefirov <sergueyz at gmail.com> writes:
>
> > 2010/10/27 Andy Stewart <lazycat.manatee at gmail.com>:
> >> Hi all,
> >>
> >> I want use TH write some function like below:
> >>
> >>  data DataType = StringT
> >>                | IntT
> >>                | CharT
> >>
> >>  parse :: [(String,DataType)] -> (TypeA, TypeB, ... TypeN)
> >>
> >> Example:
> >>
> >>  parse [("string", StringT), ("001", IntT), ("c", CharT)]
> >>
> >> will return:
> >>
> >>  ("string", 001, 'c')
> >>
> >> So how to use TH write 'parse' function?
> >
> > I think that you should use TH properly, without compiler and logical
> errors.
> >
> > What actually do you want?
> I'm build multi-processes communication program.
>
> Example i have two processes : Client and Server.
>
> At Client side, i pass [DataType] to Server, example:
>
>  [StringT, IntT, CharT]
>
> Server will handle "user input" with [DataType]
> and return result [String] to Client side, example:
>
>  ["string", "001", "c"]
>
> Then at Client side, i need parse [String] to get real value:
>
>  ("string", 001, 'c')
>
> Because, [DataType] have many different case, so i want pass [String]
> between processes, and use TH parse result [String] at Client side.
>
> Thanks,
>
>  -- Andy
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101027/1df4fa96/attachment.html


More information about the Haskell-Cafe mailing list