16

As part of my compiler, I need alex and happy to run as part of my build process. How does Stack support this scenario?

Bonus: how can I register alex and happy as compile-time dependencies?

Carl Patenaude Poulin
  • 6,238
  • 5
  • 24
  • 46

1 Answers1

14

cabal understand the suffixes .x for alex files and .y for happy files and will automatically use alex and happy to build the corresponding .hs files.

Steps to undertake:

  1. Add the .x and .y files to your extra-source-files: section
  2. Add alex and happy to your build-tools: section
  3. If your source file is Foo.Bar.x, make sure that Foo.Bar is listed in exposed-module: or in other-modules:

A good example of a package using alex and happy is the language-python package:

https://github.com/bjpop/language-python/blob/master/language-python.cabal (permalink)

Update: This is relevant to stack as well. In fact, stack will also build alex and happy for you.

Community
  • 1
  • 1
ErikR
  • 51,541
  • 9
  • 73
  • 124