rdasxy
rdasxy

Reputation: 1661

How to go back to prelude> in ghci

When I :load a Haskell script into GHCi, it changes the prompt from Prelude> to *Main>. After I'm done with this script, how can I go back to the Prelude> prompt? There seems to be no documentation regarding this.

Upvotes: 50

Views: 10664

Answers (3)

sam
sam

Reputation: 143

You can

  1. Change directory via :cd /new/directory
  2. Load another file/module. It causes the preceding module to unload.

See the definition of :cd/:load in https://downloads.haskell.org/~ghc/6.6/docs/html/users_guide/ghci-commands.html

Upvotes: 0

7hi4g0
7hi4g0

Reputation: 3799

Adding to the answer by @Tikhon Jelvis.

Apparently you can choose to unload modules using the syntax :m -<module>. As in:

Prelude> import Numeric
Prelude Numeric> :m -Numeric
Prelude> :m +Numeric
Prelude Numeric>

Source: [Haskell] Import/unimport a module into ghci

Upvotes: 16

Tikhon Jelvis
Tikhon Jelvis

Reputation: 68152

Try using the :m command. It should unload all the modules.

This is short for :module which sets the current context. You can also load arbitrary modules this way:

Prelude> :m Data.List Control.Applicative
Prelude Data.List Control.Applicative> :m
Prelude>

Upvotes: 74

Related Questions