Forrest logo
tool overview
On this page you find all important commands for the CLI tool ghci. If the command you are looking for is missing please ask our AI.

ghci

The command line tool ghci stands for GHC Interactive and is the interactive mode for the Glasgow Haskell Compiler (GHC). ghci provides a command line environment where you can directly interact with Haskell code, loading modules, and evaluating expressions in real-time.

Some key features of ghci include:

  1. Interpreter: ghci acts as an interpreter for Haskell code, allowing you to experiment, explore, and prototype Haskell programs interactively. This means you can execute expressions and observe the results immediately.

  2. REPL: It provides a Read-Eval-Print Loop (REPL) interface, where you can enter Haskell expressions or declarations, and ghci will evaluate them and print the result back to you. This makes it a powerful tool for learning and experimenting with Haskell.

  3. Type inference: ghci can infer types of expressions, which can help you understand the static type system of Haskell. This can be useful for debugging type errors and verifying the correctness of your code.

  4. Module loading: You can load Haskell modules directly into ghci and use their functions, types, and values. This facilitates incremental development and testing of modules.

  5. Debugger: GHCi also provides a debugging facility that allows you to step through code, set breakpoints, and inspect values during execution. This can be beneficial for identifying and fixing bugs in your Haskell programs.

Overall, ghci is a powerful tool for Haskell development and learning. It provides an interactive and exploratory environment that helps developers experiment with code, test hypotheses, and understand the behavior of Haskell programs.

List of commands for ghci:

  • ghc:tldr:ef70b ghc: Start a REPL (interactive shell).
    $ ghci
    try on your machine
    explain this command
  • ghci:tldr:1f7bb ghci: Start a REPL and enable some level of compiler warnings (e.g. `all` or `compact`).
    $ ghci -W${warning_level}
    try on your machine
    explain this command
  • ghci:tldr:257a4 ghci: Start a REPL and enable a language option.
    $ ghci -X${language_option}
    try on your machine
    explain this command
  • ghci:tldr:6ac89 ghci: Start a REPL and load the specified Haskell source file.
    $ ghci ${source_file-hs}
    try on your machine
    explain this command
  • ghci:tldr:ad9d7 ghci: Start a REPL with a colon-separated list of directories for finding source files.
    $ ghci -i${path-to-directory1}:${path-to-directory2}
    try on your machine
    explain this command
tool overview