<div dir="ltr">If
 you want a source file to have a module Geometry.Cuboid, it should be 
in a directory named Geometry and the file will have the name of 
Cuboid.hs.  In order to load that you have to start ghci in the directory 
that contains the Geometry directory, not in the one that contains the source file.<br><br>So cd .., ghci Geometry/Cuboid.hs<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 5, 2014 at 1:07 PM, James Toll <span dir="ltr"><<a href="mailto:james@jtoll.com" target="_blank">james@jtoll.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am trying to figure out how to import one submodule from a hierarchical module in GHCi.  For example, at the end of Chapter 6 of LYAHFGG (page 106-107), there's an example of a hierarchical module.  Or at the bottom of this page, <a href="http://learnyouahaskell.com/modules" target="_blank">http://learnyouahaskell.com/modules</a><br>

<br>
If I recreate that module on my system and try to import, this is the output:<br>
<br>
[~/Geometry]$ ls<br>
Cube.hs    Cuboid.hs  Sphere.hs<br>
[~/Geometry]$ ghci<br>
GHCi, version 7.6.3: <a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a>  :? for help<br>
Loading package ghc-prim ... linking ... done.<br>
Loading package integer-gmp ... linking ... done.<br>
Loading package base ... linking ... done.<br>
Prelude> import Geometry.Sphere<br>
<br>
<no location info>:<br>
    Could not find module `Geometry.Sphere'<br>
    It is not a module in the current program, or in any known package.<br>
Prelude> :set -iGeometry<br>
Prelude> import Geometry.Sphere<br>
<br>
<no location info>:<br>
    Could not find module `Geometry.Sphere'<br>
    It is not a module in the current program, or in any known package.<br>
Prelude> :load Sphere<br>
[1 of 1] Compiling Geometry.Sphere  ( Sphere.hs, interpreted )<br>
Ok, modules loaded: Geometry.Sphere.<br>
*Geometry.Sphere> :load Cube<br>
<br>
Cube.hs:6:18:<br>
    Could not find module `Geometry.Cuboid'<br>
    Use -v to see a list of the files searched for.<br>
Failed, modules loaded: none.<br>
Prelude> :load Cuboid<br>
[1 of 1] Compiling Geometry.Cuboid  ( Cuboid.hs, interpreted )<br>
Ok, modules loaded: Geometry.Cuboid.<br>
*Geometry.Cuboid> :load Cube<br>
<br>
Cube.hs:6:18:<br>
    Could not find module `Geometry.Cuboid'<br>
    Use -v to see a list of the files searched for.<br>
Failed, modules loaded: none.<br>
Prelude><br>
<br>
<br>
So I can't just "import Geometry.Sphere", and I tried setting -i, but that doesn't seem to help.  Instead I have to ":load Sphere".  Fine, but then when I try to ":load Cube", it fails because of the line in Cube.hs that imports Geometry.Cuboid.  Even if I load Geometry.Cuboid first and then try to load Geometry.Cube, it still fails.<br>

<br>
So, in GHCi, how do I successfully import a submodule that needs to import some other submodule in the module?<br>
<br>
Thanks,<br>
<br>
<br>
James<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>