thkang
thkang

Reputation: 11533

ghci: how to import modules in a folder

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?

Upvotes: 6

Views: 5029

Answers (1)

Rigotti
Rigotti

Reputation: 2862

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

Upvotes: 8

Related Questions