Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting GHCi prompt inside multiline blocks

Tags:

haskell

ghci

GHCi's prompt can be set as follows, which is in my .ghci:

:set prompt "λ> "

However, a different prompt appears in multiline blocks, and I can't figure out how to change it. It is completely unreadable if too many modules are imported:

λ> :{
Prelude Control.Arrow Control.Applicative Control.Monad Control.Concurrent Control.Concurrent.Async Control.Parallel Data.String Data.Char Data.List Data.Maybe Data.Monoid Control.Monad.IO.Class|

Is there a way to set this secondary prompt? Alternatively, are there other good ways to run Haskell interactively where multiline expressions are displayed in a more friendly manner?

like image 493
betaveros Avatar asked Mar 29 '14 01:03

betaveros


People also ask

How do I load a Haskell file into 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.)

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 does GHCi mean in Haskell?

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


2 Answers

You can't use prompt2 for GHC 8.2.1 and newer anymore because interface is changed. Previously it was:

   :set prompt <prompt>        set the prompt used in GHCi
   :set prompt2 <prompt>       set the continuation prompt used in GHCi

Now it's:

   :set prompt <prompt>        set the prompt used in GHCi
   :set prompt-cont <prompt>   set the continuation prompt used in GHCi
   :set prompt-function <expr> set the function to handle the prompt
   :set prompt-cont-function <expr> set the function to handle the continuation prompt

Some typical usages of these functions (just type in your GHCi or add in ~/.ghc/ghci.conf to apply settings globally):

:set prompt      λ: 
:set prompt-cont λ| 

or

:set prompt      ghci> 
:set prompt-cont ghci| 

Note: space at the end of each line

like image 115
Shersh Avatar answered Oct 19 '22 08:10

Shersh


In GHC 7.8.1 and newer, you can change the continuation prompt using :set prompt2.

See GHC #7509.

like image 38
hammar Avatar answered Oct 19 '22 08:10

hammar