How to go back to prelude> in ghci

Haskell

Haskell Problem Overview


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.

Haskell Solutions


Solution 1 - Haskell

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>

Solution 2 - Haskell

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

Solution 3 - Haskell

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionrdasxyView Question on Stackoverflow
Solution 1 - HaskellTikhon JelvisView Answer on Stackoverflow
Solution 2 - Haskell7hi4g0View Answer on Stackoverflow
Solution 3 - HaskellsamView Answer on Stackoverflow