On Fri, Dec 25, 2009 at 11:56 AM, Serguey Zefirov <span dir="ltr">&lt;<a href="mailto:sergueyz@gmail.com">sergueyz@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
A pair of problems:<br>
1) How to write a parser that could be restarted? Like, it will be<br>
represented by a function that returns something along the lines<br>
<br>
data ParseStepResult input result =<br>
    Success (Maybe (input -&gt; ParseStepResult input result)) (Maybe result)<br>
  | Failure<br></blockquote><div><br></div><div>This is basically the approach taken by the Iteratees package.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
2) How to write parser like one above that could be saved into database?<br>
<br>
data ParserCont input result = ...<br>
    deriving (Show, Read)<br>
data ParseStepResult input result =<br>
    Success (Maybe (ParserCont input result)) (Maybe result)<br>
  | Failure<br></blockquote><div><br></div><div>Yes, you&#39;ll have to defunctionalize the continuation , since you can&#39;t serialize an arbitrary function in Haskell.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I could imagine that it is possible using parser generator like Happy.<br>
<br>
Is it possible to get right using parsing combinators library?<br></blockquote><div><br></div><div>You won&#39;t find a built-in monadic parser combinator library that works this way, because of the necessary defunctionalization and the requirement that each action and intermediate result be serializable. </div>
<div><br></div><div>You could probably encode the defunctionalization of a specific parser and build up a combinator set yourself, however.</div><div><br></div><div>-Edward Kmett</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

_______________________________________________<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>
</blockquote></div><br>