[Haskell-cafe] Re: Frisby grammars that have context

Robin Green greenrd at greenrd.org
Tue May 29 19:43:51 EDT 2007


On Tue, 29 May 2007 19:28:02 -0400
Isaac Dupree <isaacdupree at charter.net> wrote:
> Luckily, Haskell's laziness means that doing an extra "postprocessing
> pass" doesn't necessarily yield two traversals requiring the whole
> file to be stored in memory, nor worse hacks.  (For grammars that
> aren't too wild / sequential)

But the suggested code fragment on the frisby homepage:

  -- parse complete file, returning 'Nothing' if parse fails
  fmap Just (myParser <<- eof) // unit Nothing

does require one traversal of the file all by itself. Obviously, in
order to know whether the file was fully parsed without error, you need
to read in the whole file, before you can write out anything. Hence
you end up with *some* representation of the whole file in memory. So,
yes, it doesn't necessarily yield two traversals, but you need to be
careful if you want to avoid two traversals.
-- 
Robin


More information about the Haskell-Cafe mailing list