Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to go back to prelude> in ghci

Tags:

haskell

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.

like image 862
rdasxy Avatar asked Feb 16 '12 04:02

rdasxy


People also ask

How do I get out of GHCi REPL?

Quits GHCi. You can also quit by typing control-D at the prompt. Attempts to reload the current target set (see :load ) if any of the modules in the set, or any dependent module, has changed.

How do I exit prelude Haskell?

You can also quit by typing a control-D at the prompt. Attempts to reload the current target set (see :load) if any of the modules in the set, or any dependent module, has changed.

How do I unload a module in Haskell?

As before, you can now use :m [+/-] My. Module to load and unload modules, but please note that this is different from :load because :module assumes you already :load ed what you're trying to get in/out of scope. you may load it by double-clicking it (on windows with winghci), by typing ghci test.

What does prelude do in Haskell?

Prelude is a module that contains a small set of standard definitions and is included automatically into all Haskell modules.


2 Answers

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> 
like image 113
Tikhon Jelvis Avatar answered Sep 22 '22 10:09

Tikhon Jelvis


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

like image 25
7hi4g0 Avatar answered Sep 19 '22 10:09

7hi4g0