location-dependent scope issue with ghci.conf
I recently noticed some of my ghci.conf
commands going wrong in newer GHCis, and have now reduced the issue to this tiny example, which ceases to work when moved from a locally sourced script to the main ghci.conf
location:
$ cat $HOME/.ghci
cat: /home/cr3/.ghci: No such file or directory
$ cat ./.ghci
cat: ./.ghci: No such file or directory
$ cat /cygdrive/c/Documents\ and\ Settings/cr3/Application\ Data/ghc/ghci.conf
let { msg () = "done" ; grep _ = return $ unlines ["let x=()","putStrLn (msg x)"] }
:def grep grep
$ cat U.hs
$ /cygdrive/c/ghc/ghc-6.9.20080514/bin/ghcii.sh U.hs
GHCi, version 6.9.20080514: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( U.hs, interpreted )
Ok, modules loaded: Main.
*Main> :grep x
<interactive>:1:10: Not in scope: `msg'
*Main> msg ()
<interactive>:1:0: Not in scope: `msg'
*Main> :q
Leaving GHCi.
$ cp /cygdrive/c/Documents\ and\ Settings/cr3/Application\ Data/ghc/ghci.conf .
$ cat ghci.conf
let { msg () = "done" ; grep _ = return $ unlines ["let x=()","putStrLn (msg x)"] }
:def grep grep
$ /cygdrive/c/ghc/ghc-6.9.20080514/bin/ghcii.sh U.hs -ignore-dot-ghci
GHCi, version 6.9.20080514: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main ( U.hs, interpreted )
Ok, modules loaded: Main.
*Main> :grep
unknown command ':grep'
use :? for help.
*Main> :cmd readFile "ghci.conf"
*Main> :grep x
done
*Main> msg ()
"done"
Trac metadata
Trac field | Value |
---|---|
Version | 6.9 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | GHCi |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture | Unknown |