GHCi doesn't find symbols when interpreting files

Peter Simons simons at cryp.to
Wed Nov 5 17:47:27 EST 2003


I'm experiencing a strange problem with the interactive
version of GHC-current. The compiler itself works just fine,
but GHCi won't find symbols in the current module when the
file is interpreted. For instance, I have a file "Main.hs":

    import System.IO

    main :: IO ()
    main = putStrLn "Hello World"

Here is a cut & paste log from the GHCi session:

    peti:/tmp$ ghci -ignore-dot-ghci Main.hs
       ___         ___ _
      / _ \ /\  /\/ __(_)
     / /_\// /_/ / /  | |      GHC Interactive, version 6.3, for Haskell 98.
    / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
    \____/\/ /_/\____/|_|      Type :? for help.

    Loading package base ... linking ... done.
    Compiling Main             ( Main.hs, interpreted )
    Ok, modules loaded: Main.
    *Main> main

    <interactive>:1: Variable not in scope: `main'
    *Main> :i main

    Variable not in scope: `main'

When I use the full name, though, it works:

    *Main> :i Main.main
    -- main :: GHC.IOBase.IO ()
    main :: GHC.IOBase.IO ()
    *Main> Main.main
    Hello World

Curiously enough, the whole problem goes away when the file
is available as an object:

    *Main> :! ghc -c Main.hs
    *Main> :l Main
    Skipping  Main             ( Main.hs, Main.o )
    Ok, modules loaded: Main.
    Prelude Main> main
    Hello World
    Prelude Main> :i main
    -- main :: IO ()
    main :: IO ()

Does anyone have an idea why this is happening? And more
importantly, how to fix it?

Peter


More information about the Cvs-ghc mailing list