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

Brent Yorgey byorgey at seas.upenn.edu
Wed Mar 5 18:47:48 UTC 2014


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

helpful.

-Brent


More information about the Beginners mailing list