[Haskell-beginners] Using GHCi, import submodule that needs to import another submodule?

James Toll james at jtoll.com
Wed Mar 5 19:12:33 UTC 2014

On Mar 5, 2014, at 12:47 PM, Brent Yorgey wrote:

> On Wed, Mar 05, 2014 at 12:39:01PM -0600, James Toll wrote:
>> 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>
> Use :add instead of :load for Geometry.Cube.  :load loads the
> specified module but forgets anything that was previously loaded.
> :add loads a module without forgetting previously loaded things.
> The differeces between :load, :add, and :module/import are somewhat
> subtle and certainly confusing.  You may find
>  http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/interactive-evaluation.html#ghci-scope

Thank you for the suggestion.  I will read up on scope and try using add.  But what I would really prefer is to be able to import individual submodules in GHCi using standard import syntax from the GHCi command line:

Prelude> import qualified Geometry.Sphere as Sphere

Is that not possible?  LYAHFFG seems to imply that it is, and Daniel’s response to this question seems to also suggest that it’s possible.  Then I can control how the functions in the submodule are referenced.

Thanks again,


More information about the Beginners mailing list