LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ghci

Interactive REPL environment for Haskell

TLDR

Start interactive session
$ ghci
copy
Load a file
$ ghci [file.hs]
copy
Load module in session
$ :load [file.hs]
copy
Get type of expression
$ :type [expression]
copy
Reload current module
$ :reload
copy

SYNOPSIS

ghci [options] [files]

DESCRIPTION

ghci is the interactive environment for GHC (Glasgow Haskell Compiler). It provides a REPL for evaluating Haskell expressions, loading modules, and exploring types interactively.GHCi supports all GHC language extensions and can compile modules on the fly. It provides introspection commands for examining types, kinds, and documentation. Tab completion and command history enhance usability.

PARAMETERS

FILES

Haskell files to load.
:load FILE
Load a module.
:reload
Reload current modules.
:type, :t EXPR
Show expression type.
:kind, :k TYPE
Show the kind of a type.
:info NAME
Show info about name, including definition and instances.
:browse MODULE
List identifiers exported by a module.
:set OPTION
Set a GHCi or compiler option for the session.
:main ARGS
Run the program's `main` with the given arguments.
:quit, :q
Exit GHCi.
-i DIR1:...:DIRn
Add directories to the source file search path.
--help
Display help information.

CONFIGURATION

~/.ghci

Per-user startup file loaded when GHCi starts, containing default settings, imports, and custom commands.
./.ghci
Project-local startup file loaded after the user file (must have safe permissions to be read).

CAVEATS

Some compiled code may behave differently in interpreter. Memory usage can grow with large expressions. Restart clears interpreter state.

HISTORY

GHCi was introduced with GHC 5.0 in 2001, providing interactive Haskell evaluation alongside the batch compiler.

SEE ALSO

ghc(1), ghcid(1), cabal(1), stack(1), runghc(1)

Copied to clipboard
Kai