Reputation: 811
I created a small module and I want to use it in my program. I’m able to import it in the program and use it. However, I’m not able to import it in ghci. This is causing a lot of problems as I’m not able to test things interactively which I’d like to.
Essentially, I’m creating Geometry.hs from here (http://learnyouahaskell.com/modules#making-our-own-modules) and trying to import it in my program which works. If I do the same thing in ghci, it doesn’t. I run ghci from the same directory where Geometry.hs is present.
This is my program.
import Geometry
main = putStrLn $ show $ Geometry.sphereVolume 1
I try to execute the same lines in ghci and get this error -
<no location info>:
Could not find module `Geometry'
It is not a module in the current program, or in any known package.
Upvotes: 1
Views: 1555
Reputation: 54058
Just so that we keep our answered questions ratio high on the Haskell tag, the solution was to use the :load
or :l
directives in GHCi to load the source file in the current directory. As @Zeta notes, the documentation with more details can be found at http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-evaluation.html#ghci-scope
Upvotes: 1