GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2022-09-22T19:07:27Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/22137runghc examples2022-09-22T19:07:27ZGhost Userrunghc exampleshttps://gitlab.haskell.org/ghc/ghc/-/issues/21411
_a somewhat lengthy ticket closed Jul 4, 2022_
Recently I took another look at the runghc code.
utils/runghc/Main.hs
utils/runghc/runghc.cabal.in
This could be rewritten not using l...https://gitlab.haskell.org/ghc/ghc/-/issues/21411
_a somewhat lengthy ticket closed Jul 4, 2022_
Recently I took another look at the runghc code.
utils/runghc/Main.hs
utils/runghc/runghc.cabal.in
This could be rewritten not using literate Haskell.
```
$ sed 17q ghc/utils/runghc/Main.hs
{-# LANGUAGE CPP #-}
#include <ghcplatform.h>
-----------------------------------------------------------------------------
--
-- (c) The University of Glasgow, 2004
--
-- runghc program, for invoking from a #! line in a script. For example:
--
-- script.lhs:
-- #!/usr/bin/env runghc
-- > main = putStrLn "hello!"
--
-- runghc accepts one flag:
--
-- -f <path> specify the path
--
-- -----------------------------------------------------------------------------
$
```
rewrite
```diff
- -- script.lhs:
+ -- script.hs:
-- #!/usr/bin/env runghc
- -- > main = putStrLn "hello!"
+ -- main = putStrLn "hello!"
```
https://gitlab.haskell.org/ghc/ghc/-/commit/e32a6e1f4ac847272598776fd15f4a98069690e5
This file looks as if it has an improperly written here document.
_perhaps it's just an errant redirect symbol_
```
$ ed -s ghc/utils/runghc/runghc.cabal.in <<<'10,20p'
@runghc@ is a small wrapper program around GHC which allows the compiler
to be used as a UNIX-style script interpreter. For instance,
.
@
$ cat > Hi.hs
\#!/usr/bin/env runghc
main = putStrLn "hello!"
$ chmod u+x Hi.hs
$ ./Hi.hs
hello!
@
$
```
A properly written here document in a shell.
```
$ cat <<EOF > Hi.hs
> #!/usr/bin/env runghc
> main = putStrLn "hello!"
> EOF
$
```
The `runghc.cabal.in` extract appears to escape the `#` character.
@bgamari
Is escaping characters in `@ @` sections documented somewhere?Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21810runghc doesn't respect -pgmF2022-07-05T15:43:09ZBrandon Chinnrunghc doesn't respect -pgmF## Summary
`runghc` doesn't seem to support registering a preprocessor. Is this expected?
## Steps to reproduce
```bash
# fails as expected with "could not execute: foo"
ghc AnyFile.hs -F -pgmF=foo
# tries to compile without checking...## Summary
`runghc` doesn't seem to support registering a preprocessor. Is this expected?
## Steps to reproduce
```bash
# fails as expected with "could not execute: foo"
ghc AnyFile.hs -F -pgmF=foo
# tries to compile without checking foo
runghc AnyFile.hs -- -F -pgmF=foo
```
## Expected behavior
It should work. If this is intentional, the docs for runghc should be updated to include the differences with ghc. The documentation currently seems to indicate that flags are passed directly to GHC (and should thus be respected).
## Environment
* GHC version used: 9.2.3
Optional:
* Operating System:
* System Architecture:Matthew PickeringMatthew Pickeringhttps://gitlab.haskell.org/ghc/ghc/-/issues/19667magicDict crashes runghc, but not compiled code2022-05-25T10:48:12ZRyan ScottmagicDict crashes runghc, but not compiled codeConsider the following program, which uses `GHC.Exts.magicDict`:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
module Main (main) where
import Data.Proxy (Proxy(..))
import GHC.Exts (magic...Consider the following program, which uses `GHC.Exts.magicDict`:
```hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
module Main (main) where
import Data.Proxy (Proxy(..))
import GHC.Exts (magicDict)
import GHC.TypeLits (KnownSymbol, Symbol, symbolVal)
data WrapS a b = WrapS (KnownSymbol a => Proxy a -> b)
reifySymbol :: forall r. String -> (forall (n :: Symbol). KnownSymbol n => Proxy n -> r) -> r
reifySymbol n k = magicDict (WrapS k) n Proxy
main :: IO ()
main = print $ reifySymbol "Hello World" symbolVal
```
This works if I compile the program and run it:
```
$ /opt/ghc/9.0.1/bin/ghc Bug.hs && ./Bug
[1 of 1] Compiling Main ( Bug.hs, Bug.o )
Linking Bug ...
"Hello World"
```
However, it crashes if I invoke it with `runghc`:
```
$ /opt/ghc/9.0.1/bin/runghc Bug.hs
ghc: ^^ Could not load 'ghczmprim_GHCziPrim_magicDict_closure', dependency unresolved. See top entry above.
Bug.hs:
GHC.ByteCode.Linker.lookupCE
During interactive linking, GHCi couldn't find the following symbol:
ghczmprim_GHCziPrim_magicDict_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please report this as a GHC bug:
https://www.haskell.org/ghc/reportabug
```
I would expect both versions to work.https://gitlab.haskell.org/ghc/ghc/-/issues/17171`runghc` accepts invalid main program (for GHC 8.8.1)2020-03-22T17:02:46ZHerbert Valerio Riedelhvr@gnu.org`runghc` accepts invalid main program (for GHC 8.8.1)Consider the `Main` module
```
module Main () where main = putStrLn "The impossible happened"
```
which according to the Haskell Report does not constitute a valid Haskell Program (as it doesn't export the `main` entry point)
Compilin...Consider the `Main` module
```
module Main () where main = putStrLn "The impossible happened"
```
which according to the Haskell Report does not constitute a valid Haskell Program (as it doesn't export the `main` entry point)
Compiling this with `ghc --make` will rightly reject it with
```
Main.hs:1:1: error:
The IO action ‘main’ is not exported by module ‘Main’
|
1 | module Main () where main = putStrLn "The impossible happened"
| ^
```
However, `runghc Main.hs` (starting with GHC 8.8.1) will happily run this invalid program:
```
$ runghc Main.hs
The impossible happened
```
This inconsistent behaviour has lead to less informed people assuming such a program might be actually "valid" Haskell.8.8.2Roland SennRoland Senn