Importing modules in .ghci file doesn't work
|Reported by:||m4dc4p||Owned by:|
|Operating System:||MacOS X||Architecture:||x86_64 (amd64)|
|Type of failure:||None/Unknown||Difficulty:||Unknown|
|Test Case:||Blocked By:|
When attempting to import a module in the .ghci file, GHCi does not seem to use the search path.
Define a module names "Macros.hs":
module Macros where hello :: String -> IO String hello msg = return ("putStrLn " ++ show msg)
Now, in the same directory, create a .ghci file:
import Macros :def hello hello
Run GHCi from that same directory, and you get an error:
$ ghci GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. <no location info>: Could not find module `Macros' It is not a module in the current program, or in any known package. <interactive>:1:25: Not in scope: `hello'
It seems that GHCi should be able to find "Macros.hs", compile it, and all me to use it in defining macros.
Adding the current directory (relative or absolute) to the search path (using -i) doesn't help.
Why do I want to do this? I want to define GHCi macros in a separate module (that is not related to my program) and import them, rather than defining them directly in the .ghci file.
Change History (8)
comment:2 Changed 4 months ago by m4dc4p
- Summary changed from Importing modules in .ghci file doesn't not work to Importing modules in .ghci file doesn't work
comment:5 Changed 4 months ago by m4dc4p
- Resolution set to invalid
- Status changed from new to closed