[Haskell-cafe] Parallel parsing & multicore

Anakim Border akborder at gmail.com
Wed Sep 9 15:58:58 EDT 2009

Hi Edward,

I read your slides a few weeks ago when they were posted on Reddit and
found your approach very interesting. In fact it provided the
inspiration for the parser I've written.

I did not use the same strategy, however, because parsing makefiles
poses its own challenges. The make syntax is actually the union of two
different languages, one for defining targets and one for commands.
It's easy to identify commands following target definitions (they
belong to lines starting with a tab), but if you jump to the middle of
a makefile you can't decide, for example, if you are inside a define
block (that should be parsed like a command) because the lines in its
body are not marked by any specific prefix. Thus the need for a
sequential scan. All this may seem rather involved and specific to an
unusual format, but one encounters the same problem when parsing
here-documents in shell scripts or multi line (triple-quoted) comments
in Python.

The cache trashing effect you mention is certainly an issue I did not
foresee. I guess a possible solution would be to base parMap on
different 'par' primitive; one that sparks a number of computations
equal to the number of available OS threads and then blocks until at
least one of them is done.

-- AB

More information about the Haskell-Cafe mailing list