How do Happy and Alex bootstrap themselves into being?
Asked Answered
N

1

10

The source tree for happy contains AttrGrammarParser.ly and Parser.ly and the source tree for alex contains Scan.x. Yet, as far as I can tell in order to compile happy, we need to transform the .ly files into .lhs files using... happy, and in order to compile alex we need to transform the .x files into .hs files using... alex.

So it seems like there must be some bootstrapping going on here in order to compile either tool.

The Setup.lhs files for each project contain some template expansion, but, as far as I can tell, don't do anything in particular to do the bootstrapping.

How and where is the bootstrapping done?

Neper answered 4/2, 2015 at 2:55 Comment(0)
R
10

I see that you are looking at the source tree of the darcs repositories for these packages on darcs.haskell.org. If you look at the actual tarballs on Hackage, you'll see something a bit different:

https://hackage.haskell.org/package/alex-3.1.4/src/dist/build/alex/alex-tmp/

https://hackage.haskell.org/package/happy-1.19.5/src/dist/build/happy/happy-tmp/

So basically the build artifacts necessary are shipped with the Hackage tarball. Cabal then just uses the build artifacts during the build process, thus avoiding the need to bootstrap locally. Cabal also knows how to preserve such build artifacts when you run cabal sdist for your own packages which you want not to depend on happy or alex, but last I checked this doesn't interoperate well with sandboxes, fwiw.

By the way, alex and happy development has moved to github:

https://github.com/simonmar/alex/

https://github.com/simonmar/happy/

Rosaliarosalie answered 4/2, 2015 at 3:4 Comment(1)
Ah ok. Someone had given me a source ball for the haskell platform, and the version they'd grabbed, for some reason, didn't have the generated sources in it. I was wondering why it didn't build on my system, and now I know.Neper

© 2022 - 2024 — McMap. All rights reserved.