Popular tips

How do I quit ghci?

How do I quit ghci?

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 run ghci?

GHCi. GHCi is the interactive interface to GHC. From the command line, enter “ghci” (or “ghci -W”) followed by an optional filename to load. Note: We recommend using “ghci -W”, which tells GHC to output useful warning messages in more situations.

How do I run ghci in terminal?

If you have installed the Haskell Platform, open a terminal and type ghci (the name of the executable of the GHC interpreter) at the command prompt. Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. And you are presented with a prompt. The Haskell system now attentively awaits your input.

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 to find a source file in GHCi?

The search path for finding source files is specified with the -i option on the GHCi command line, like so: or it can be set using the :set command from within GHCi (see Setting GHC command-line options in GHCi) [4] One consequence of the way that GHCi follows dependencies to find modules to load is that every module must have a source file.

What do you do with the SET command in GHCi?

The :set command can be used to change various behaviors of GHCi from within a running REPL. Options set with the :set command can be undone with the :unset command. If you want them on each time you open a new GHCi session, options set with the :set or :seti command can also be enabled in your GHCi configuration file.

How to load a Haskell source file into GHCi?

To load a Haskell source file into GHCi, use the :load command: GHCi has loaded the Main module, and the prompt has changed to *ghci> to indicate that the current context for expressions typed at the prompt is the Main module we just loaded (we’ll explain what the * means later in What’s really in scope at the prompt? ).

Why do we need to run compiled code in GHCi?

When you load a Haskell source module into GHCi, it is normally converted to byte-code and run using the interpreter. However, interpreted code can also run alongside compiled code in GHCi; indeed, normally when GHCi starts, it loads up a compiled copy of the base package, which contains the Prelude. Why should we want to run compiled code?