I'm trying to run some Safe Haskell code with runghc, but it doesn't seem to work for me.
bgeron@tinker:/tmp/wtf$ ls
Strange.hs
bgeron@tinker:/tmp/wtf$ cat Strange.hs
module Strange where
main :: IO ()
main = do
return ()
bgeron@tinker:/tmp/wtf$ runghc -XSafe Strange
Strange:1:1: Not in scope: `System.Environment.withArgs'
bgeron@tinker:/tmp/wtf$ runghc --version
runghc 7.6.3
I thought this would be a valid use of runghc; the error is most confusing. Is this a bug?
I'm using Ubuntu 14.04, 64-bit.
The observed behaviour can be explained by the following.
The implementation of runghc is here:
https://ghc.haskell.org/trac/ghc/browser/ghc/utils/runghc/runghc.hs
It will make the following call to ghc, which also shows the strange behaviour:
ghc -XSafe -e ':main' Strange.hs
The implementation of ghc in evalatue-expression mode will add the offending import: https://ghc.haskell.org/trac/ghc/browser/ghc/ghc/InteractiveUI.hs#L1154
I am not sure whether it's a bug. I agree it's confusing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With