When building with GHCJS happy is built but not used.
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
When building with GHCJS happy is built but not used.
**To Reproduce**
Check that there are no `happy` in path. Try to build package using `happy`.
Given a simple package
```
cabal-version: 2.4
name: ha
version: 0
library
default-language: Haskell2010
build-depends: base, array
build-tool-depends: happy:happy
exposed-modules: Calc
```
where `Calc.ly` is a Happy example: https://github.com/simonmar/happy/blob/master/examples/Calc.ly (change `import Char` to `import Data.Char`)
```
$ cabal v2-build --ghcjs -w /opt/ghcjs/8.4/bin/ghcjs
```
fails with
```
Warning: don't know how to find change monitoring files for the installed
package databases for ghcjs
Resolving dependencies...
Build profile: -w ghcjs-8.4.0.1 -O1
In order, the following will be built (use -v for more details):
- ha-0 (lib) (configuration changed)
Configuring library for ha-0..
cabal: The program 'happy' is required but it could not be found.
```
**Expected behavior**
Things should work. E.g. with `ghc` (happy is cached)
```
% cabal new-build -w ghc-8.6.5
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- ha-0 (lib) (first run)
Configuring library for ha-0..
Preprocessing library for ha-0..
Building library for ha-0..
[1 of 1] Compiling Calc ( /code/mess/ha/dist-newstyle/build/x86_64-linux/ghc-8.6.5/ha-0/build/Calc.hs, /code/mess/ha/dist-newstyle/build/x86_64-linux/ghc-8.6.5/ha-0/build/Calc.o )
```
**System informataion**
- Operating system: Ubuntu-18.04
- `cabal-install-3.0`
**Additional context**
`cabal` does build `happy` with`ghcjs`: (note https://github.com/simonmar/happy/issues/144)
```
% cabal new-build --ghcjs -w /opt/ghcjs/8.4/bin/ghcjs
Warning: don't know how to find change monitoring files for the installed
package databases for ghcjs
Resolving dependencies...
Build profile: -w ghcjs-8.4.0.1 -O1
In order, the following will be built (use -v for more details):
- happy-1.19.11 (exe:happy) (requires build)
- ha-0 (lib) (first run)
Starting happy-1.19.11 (all, legacy fallback)
Building happy-1.19.11 (all, legacy fallback)
Installing happy-1.19.11 (all, legacy fallback)
Completed happy-1.19.11 (all, legacy fallback)
Configuring library for ha-0..
cabal: The program 'happy' is required but it could not be found.
```
And that "executable" is usable:
```
% node /cabal/store/ghcjs-8.4.0.1/happy-1.19.11-5b79cbab37ec6f3d0c701cbe20d7217ae8f56d5d04025e25e89b5db1036bc065/bin/happy.jsexe/all.js
Usage: all.js [OPTION...] file
-o FILE --outfile=FILE write the output to FILE (default: file.hs)
-i[FILE] --info[=FILE] put detailed grammar info in FILE
-p[FILE] --pretty[=FILE] pretty print the production rules to FILE
-t DIR --template=DIR look in DIR for template files
-m NAME --magic-name=NAME use NAME as the symbol prefix instead of "happy"
-s --strict evaluate semantic values strictly (experimental)
-g --ghc use GHC extensions
-c --coerce use type coercions (only available with -g)
-a --array generate an array-based parser
-d --debug produce a debugging parser (only with -a)
-l --glr Generate a GLR parser for ambiguous grammars
-k --decode Generate simple decoding code for GLR result
-f --filter Filter the GLR parse forest with respect to semantic usage
-? --help display this help and exit
-V, -v --version output version information and exit
```
Maybe it's not the best idea to use that one for `haskell-src-exts`, but that's another issue. Cabal should be able to call it.
Contributor guide
Research direction
Start by reproducing the package from the issue with cabal v2-build --ghcjs and the shown GHCJS compiler, checking how the built happy executable is located and invoked. Done means the example package can preprocess and build with GHCJS when happy is declared through build-tool-depends, without requiring happy on PATH.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100