[Haskell-beginners] Using GHCi, import submodule that needs to import another submodule?
James Toll
james at jtoll.com
Wed Mar 5 18:39:01 UTC 2014
On Mar 5, 2014, at 12:17 PM, Daniel Trstenjak wrote:
> Hi James,
>
> On Wed, Mar 05, 2014 at 12:07:33PM -0600, James Toll wrote:
>> So, in GHCi, how do I successfully import a submodule that needs to import some other submodule in the module?
>
> [~/Geometry]$ cd ..
> [~]$ ghci
>> import Geometry.Sphere
Hi Daniel,
Thank you for your suggestion. It appears that your suggestion partially works. Picking up from where I left off previously:
Prelude> :q
Leaving GHCi.
[~/Geometry]$ cd ..
[~/]$ ls
Geometry/ clang-xcode5-wrapper.hs test.hs
[~/]$ 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.
Prelude> import Geometry.Sphere
<no location info>:
Could not find module `Geometry.Sphere'
It is not a module in the current program, or in any known package.
Prelude> :load Sphere
<command line>:
Could not find module `Sphere'
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
Prelude> :load Geometry.Sphere
[1 of 1] Compiling Geometry.Sphere ( Geometry/Sphere.hs, interpreted )
Ok, modules loaded: Geometry.Sphere.
*Geometry.Sphere> :load Geometry.Cube
[1 of 2] Compiling Geometry.Cuboid ( Geometry/Cuboid.hs, interpreted )
[2 of 2] Compiling Geometry.Cube ( Geometry/Cube.hs, interpreted )
Ok, modules loaded: Geometry.Cube, Geometry.Cuboid.
*Geometry.Cube>
So import still does not work. But by trying “:load" from the parent directory, I was able to load Sphere, Cube and Cuboid. The problem is that it appears that only one is available at a time (i.e. loading Cube displaces Sphere). What’s more there is no way to do qualified imports.
Regards,
James
More information about the Beginners
mailing list