Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GHCI vs Prelude command prompt in Haskell

Tags:

haskell

ghci

I am trying to learn Haskell from the beginning and was wondering what exactly is the difference between the two prompts (Haskell and Prelude) that are used in it. It may sound a very naive question and not to mention I tried searching for the answer before posting this question but couldn't find one (proper one). Thank you in advance.

like image 245
Yogesh D Avatar asked Feb 03 '16 02:02

Yogesh D


People also ask

What is Prelude in Ghci?

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

What is the difference between GHC and Ghci?

Introduction. GHCi is GHC's interactive environment, in which Haskell expressions can be interactively evaluated and programs can be interpreted.

How do I run a Haskell file in Ghci?

Open a command window and navigate to the directory where you want to keep your Haskell source files. Run Haskell by typing ghci or ghci MyFile. hs. (The "i" in "GHCi" stands for "interactive", as opposed to compiling and producing an executable file.)

How do I get out of Haskell Prelude?

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. Note that this may entail loading new modules, or dropping modules which are no longer indirectly required by the target.


1 Answers

Okay, if I'm understanding this correctly, you're wondering if there's a difference between

Prelude> 

and

ghci>

as prompts after you've invoked GHCi from the command line.

If this is the case, then there is no real difference aside from preference. You can change the prompt to whatever you want to by using the command:

:set prompt "aglebargle> "

You can replace arglebargle> with whatever you'd like.

The main advantage I see for the Prelude> prompt is that it will update when you import modules. Prelude is the only module you have without any imports, which is why it's the prompt. E.g., if you, say, did import Control.Monad, you'd get Prelude Control.Monad> as a prompt.

like image 121
the spectre Avatar answered Sep 24 '22 17:09

the spectre