Forrest logo
back to the ghc tool

ghc:tldr:d223c

ghc: Evaluate a single expression.
$ ghc -e ${expression}
try on your machine

The command "ghc -e ${expression}" is used to evaluate and execute a Haskell expression directly from the command line using the GHC (Glasgow Haskell Compiler). Here's a breakdown of the command: - "ghc": This is the command to run the GHC compiler.

  • "-e": This flag specifies that we want to evaluate an expression.
  • "${expression}": This is the Haskell expression that you want to evaluate. You can replace "${expression}" with the actual expression you want to evaluate. When you execute this command, GHC will compile the expression and then execute it, displaying the result on the command line. For example, if you want to evaluate the expression "2 + 2", you would run the command: ghc -e "2 + 2" The output will be: 4 This command is useful for quickly testing small Haskell expressions without the need to write a full Haskell file and compile it separately.
This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ghc tool