<HTML dir=ltr><HEAD><TITLE>Re: [clean-list] Parser, why three type variables</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.6000.16608" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText64335 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>Hi,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>So sorry for the noise I emitted. I should have said that I only need two *continuations* instead of three. I don't need the XOR-continuation. Taking that out is not trivial for me. But all of this is irrelevant to Carlos' question.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>Erik</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>Van:</B> Pieter Koopman [mailto:pieter@cs.ru.nl]<BR><B>Verzonden:</B> di 6-5-2008 12:00<BR><B>Aan:</B> zuurb078@planet.nl<BR><B>CC:</B> Carlos Aya; clean-list@science.ru.nl<BR><B>Onderwerp:</B> Re: [clean-list] Parser, why three type variables<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Hi,<BR><BR>my parser library has parsers with 3 type parameters: Parser s r t.<BR>s is the type of the symbols parsed (the tokens)<BR>r is the result of this parser. The type r can be identical to s (for<BR>instance for the combinator symbol), but often is it a (part of) syntax tree<BR>t is the final result. Rather than constructing some intermediate data<BR>type, my parser combinators use continuations to handle the parser<BR>results. The success continuation transforms the parse results of type r<BR>to elements of type t. Basically the success continuation acts like a<BR>function of type r->t.<BR>That is the reason I needed those 3 type arguments, see<BR><A href="http://www.st.cs.ru.nl/papers/1999/koop98-EffCombParsIFL98.ps.gz">http://www.st.cs.ru.nl/papers/1999/koop98-EffCombParsIFL98.ps.gz</A> for<BR>details.<BR><BR>Hope this helps,<BR><BR>Pieter Koopman<BR><BR>Erik Zuurbier wrote:<BR>> Carlos,<BR>><BR>> I wrote those parser combinators based on Pieter Koopman's work with<BR>> only two type parameters. Pieter also has a version with three type<BR>> parameters, necessary for the XOR-combinator and the way he improved<BR>> the library's efficiency. I did not like that approach and found a<BR>> different way. See the help file that comes with the library.<BR>><BR>> But after that Pieter found a bug that appeared in both of his<BR>> libraries but solved it only for his 3-parameter library. I could not<BR>> solve it for the 2-parameter library so I reworked my parser library<BR>> based on his improved 3-parameter library.<BR>><BR>> It is true, the parser library that emits error messages does not need<BR>> the third parameter, but to my opinion it is not trivial to take it<BR>> out. Hope Pieter reads this and will once find the time to debug his<BR>> 2-parameter library as well, after which I can base the error-message<BR>> emitting library on it.<BR>><BR>> Regards<BR>> Erik Zuurbier<BR>> ----- Original Message ----- From: "Carlos Aya" <carlosayam@yahoo.com.au><BR>> To: <clean-list@science.ru.nl><BR>> Sent: Sunday, May 04, 2008 5:48 AM<BR>> Subject: [clean-list] Parser, why three type variables<BR>><BR>><BR>>> Hello,<BR>>><BR>>> In the parsers library one finds...<BR>>><BR>>> :: Parser s r t<BR>>><BR>>> and<BR>>><BR>>> parse :: !(Parser s r r) [s] String String -> Result r<BR>>><BR>>> Still not clear for me, from a software design point of view, why<BR>>> three type variables in 'Parse' if 'parse' use only 2 in the type?<BR>>> Why we want the type engine to have that free 't' around? I saw the<BR>>> combinators and none of them touch it... hope I didn't overlooked<BR>>> something... any help appreciated.<BR>>><BR>>> regards<BR>>> Carlos<BR>>><BR>>><BR>>><BR>>> Get the name you always wanted with the new y7mail email address.<BR>>> www.yahoo7.com.au/y7mail<BR>>><BR>>><BR>>><BR>>> _______________________________________________<BR>>> clean-list mailing list<BR>>> clean-list@science.ru.nl<BR>>> <A href="http://mailman.science.ru.nl/mailman/listinfo/clean-list">http://mailman.science.ru.nl/mailman/listinfo/clean-list</A><BR>><BR>> _______________________________________________<BR>> clean-list mailing list<BR>> clean-list@science.ru.nl<BR>> <A href="http://mailman.science.ru.nl/mailman/listinfo/clean-list">http://mailman.science.ru.nl/mailman/listinfo/clean-list</A><BR></FONT></P></DIV></BODY></HTML>