target "is not a module name or a source file"
Create a standalone Haskell program "/tmp/delme.hs". Then do
$ cd /tmp
{- 0 -}$ ghc --make -o delme.exe /tmp/delme.hs
[1 of 1] Compiling Main ( /tmp/delme.hs, /tmp/delme.o )
Linking delme.exe ...
$ rm delme.o
{- 1 -}$ ghc --make -o delme.exe /tmp/delme
[1 of 1] Compiling Main ( /tmp/delme.hs, /tmp/delme.o )
Linking delme.exe ...
$ rm delme.o
$ mv delme.hs delme
{- 2 -}$ ghc --make -o delme.exe /tmp/delme
target `/tmp/delme' is not a module name or a source file
We see that:[[BR]]
- in "1" GHC compiles "/tmp/delme.hs" though I say "/tmp/delme";[[BR]]
- in "2" GHC can not see file "/tmp/delme".
The problem is that a target (the last argument) may be a module name or a source file. GHC uses heuristics to determine this. Though heuristics may seem neat and clever, they draw GHC more intricate and unpredictable (see also KISS).
I encountered this intricacy when ran "ghc" on a shell script. Shell scripts in Unix commonly do not have extensions, because interpreter name is included in a shell script. And "runghc" runs them fine. "ghc" in theory also does not require a file to have an extension because it clearly contains Haskell source code — what else?
I propose to introduce a GHC flag which says explicitly which type a target is of.
Trac metadata
Trac field | Value |
---|---|
Version | 6.12.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |