Multi module script support
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
shebang script interpreter fails if the script spans over multiple modules
**To Reproduce**
ghc compiles this program successfully.
```
$ cat OtherModule.hs
module OtherModule (hello) where
hello :: String
hello = "hello"
$ cat hello.hs
#! /usr/bin/env cabal
{- cabal:
build-depends: base
ghc-options: -Wall
-}
module Main where
import Example.Hello (hello)
main = putStrLn hello
$ ghc hello.hs
[1 of 2] Compiling OtherModule ( OtherModule.hs, OtherModule.o )
Linking hello ...
```
But `cabal run` fails:
```
$ cabal v2-run hello.hs
Resolving dependencies...
Build profile: -w ghc-8.8.3 -O1
In order, the following will be built (use -v for more details):
- fake-package-0 (exe:script) (first run)
Configuring executable 'script' for fake-package-0..
Preprocessing executable 'script' for fake-package-0..
Building executable 'script' for fake-package-0..
[1 of 1] Compiling Main ( Main.hs, /var/folders/p4/fdt36vy95f52t_3dnpcx8_340000gn/T/cabal-repl.-24197/dist-newstyle/build/x86_64-osx/ghc-8.8.3/fake-package-0/x/script/build/script/script-tmp/Main.o )
Main.hs:7:1: error:
Could not find module ‘OtherModule’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
7 | import OtherModule (hello)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
```
**Expected behavior**
`cabal` script interpreter should be able to compile and run the above program.
**System information**
- Mac OSX
```
$ cabal --version
cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.3
```
Contributor guide
Assessment
This issue has not been assessed yet.