8.2. Compilation-Time Tips
Prev | Chapter 8. Tips | Next

## 8.2. Compilation-Time Tips

We have found that compiling parsers generated by Happy can take a large amount of time/memory, so here's some tips on making things more sensible:

- Include as little code as possible in the module trailer. This code is included verbatim in the generated parser, so if any of it can go in a separate module, do so.

- Give type signatures for everything (see Section 2.4, “Type Signatures”. This is reported to improve things by about 50%. If there is a type signature for every single non-terminal in the grammar, then Happy automatically generates type signatures for most functions in the parser.

- Simplify the grammar as much as possible (applies to everything, this one).

- Use a recent version of GHC. Versions from 4.04 onwards have lower memory requirements for compiling Happy-generated parsers.

- Using Happy's `-g -a -c` options when generating parsers to be compiled with GHC will help considerably.

Prev | Up | Next
Chapter 8. Tips | Home | 8.3. Finding Type Errors