On 3 Aug 2013, at 02:20, Jason Dagit wrote:

>> Hi!
>> Is there any specific reason why GHC is written in a parser GENERATOR
>> (Happy) and not in MONADIC PARSER COMBINATOR (like parsec)?
>> 
>> Is Happy faster / handles better errors / hase some great features or
>> anything else?
> 
> One reason is that  it predates monadic parser libraries.

I'm not entirely sure this is true.  I reckon the development of applicative 
parser combinators (used in the implementation of the nhc12 compiler, way back 
in 1995 or so), is roughly contemporaneous with the development of Happy, and 
its use inside ghc.  (I found a release note from Sept 1997 that said ghc had 
just converted its interface-file parser to use Happy.)  Certainly table-driven 
parsers in non-functional languages go back a lot further, and functional 
combinator-based parsing was then the relative newcomer.

As to why ghc switched to Happy, the literature of the time suggests that 
generated table-driven parsers were faster than combinator-based parsers.  I'm 
not sure I have ever seen any performance figures to back that up however.  And 
with the general improvement in performance of idiomatic Haskell over the last 
twenty years, I'd be interested to see a modern comparison.

Regards,
    Malcolm



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to