4
votes

After updating from ghc 7.6 to 7.10 it seems you can't :m [Module] or ghci> import [Module] where [Module.hs] is your hand-written module file that resides in current working directory.

It seems ghci searches only for modules that are part of haskell standard library and modules that are globally installed via cabal. (you can still :load [Module.hs] in ghci prompts though)

I think it's kinda annoying since you can't test whether my module definition is correct by directly importing them from ghci. Is there any switch or configuration that I can fiddle with, so I can tell where my haskell working dirctory is to ghci?

1
just throw a .cabal into the folder exposing your module and it should work - Random Dev
I don't understand. If :load works, why not just use that? - sclv
You can still use :m or import on "local" modules, it's just that now all modules must be loaded before calling either of these commands on them (I believe it would previously load the module automatically if it wasn't loaded?). So just do :l Module.hs ; :m + Module. - user2407038
The answer and comment above have it right; I just want to point out that #7416 is relevant. You can load multiple modules with :l Module1.hs Module2.hs ..., but only Module1.hs is imported. You have to :m +Module2 ... to import the rest. - crockeea
@sclv :load is slightly different, it loads all functions in the file, not just the ones exported by the module (i.e. module Foo (a,b,c) where...). - xdavidliu

1 Answers

6
votes

Not a very useful way, but if you want to achieve this old behavior, you have to load the file that contains the module

ghci> :l File.hs

Hide/remove all the modules you don't want

ghci> :m

The module imported from the file is now available

ghci> :m YourModule