<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-&gt;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>&gt; Carlos,<BR>&gt;<BR>&gt; I wrote those parser combinators based on Pieter Koopman's work with<BR>&gt; only two type parameters. Pieter also has a version with three type<BR>&gt; parameters, necessary for the XOR-combinator and the way he improved<BR>&gt; the library's efficiency. I did not like that approach and found a<BR>&gt; different way. See the help file that comes with the library.<BR>&gt;<BR>&gt; But after that Pieter found a bug that appeared in both of his<BR>&gt; libraries but solved it only for his 3-parameter library. I could not<BR>&gt; solve it for the 2-parameter library so I reworked my parser library<BR>&gt; based on his improved 3-parameter library.<BR>&gt;<BR>&gt; It is true, the parser library that emits error messages does not need<BR>&gt; the third parameter, but to my opinion it is not trivial to take it<BR>&gt; out. Hope Pieter reads this and will once find the time to debug his<BR>&gt; 2-parameter library as well, after which I can base the error-message<BR>&gt; emitting library on it.<BR>&gt;<BR>&gt; Regards<BR>&gt; Erik Zuurbier<BR>&gt; ----- Original Message ----- From: "Carlos Aya" &lt;carlosayam@yahoo.com.au&gt;<BR>&gt; To: &lt;clean-list@science.ru.nl&gt;<BR>&gt; Sent: Sunday, May 04, 2008 5:48 AM<BR>&gt; Subject: [clean-list] Parser, why three type variables<BR>&gt;<BR>&gt;<BR>&gt;&gt; Hello,<BR>&gt;&gt;<BR>&gt;&gt; In the parsers library one finds...<BR>&gt;&gt;<BR>&gt;&gt; :: Parser s r t<BR>&gt;&gt;<BR>&gt;&gt; and<BR>&gt;&gt;<BR>&gt;&gt; parse :: !(Parser s r r) [s] String String -&gt; Result r<BR>&gt;&gt;<BR>&gt;&gt; Still not clear for me, from a software design point of view, why<BR>&gt;&gt; three type variables in 'Parse' if 'parse' use only 2 in the type?<BR>&gt;&gt; Why we want the type engine to have that free 't' around? I saw the<BR>&gt;&gt; combinators and none of them touch it... hope I didn't overlooked<BR>&gt;&gt; something... any help appreciated.<BR>&gt;&gt;<BR>&gt;&gt; regards<BR>&gt;&gt; Carlos<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Get the name you always wanted with the new y7mail email address.<BR>&gt;&gt; www.yahoo7.com.au/y7mail<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt;<BR>&gt;&gt; _______________________________________________<BR>&gt;&gt; clean-list mailing list<BR>&gt;&gt; clean-list@science.ru.nl<BR>&gt;&gt; <A href="http://mailman.science.ru.nl/mailman/listinfo/clean-list">http://mailman.science.ru.nl/mailman/listinfo/clean-list</A><BR>&gt;<BR>&gt; _______________________________________________<BR>&gt; clean-list mailing list<BR>&gt; clean-list@science.ru.nl<BR>&gt; <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>