LinuxCommandLibrary

ghc

Compiler for the Haskell functional programming language

TLDR

Compile a Haskell file

$ ghc [file.hs]
copy
Compile with optimization
$ ghc -O2 [file.hs]
copy
Compile to object file
$ ghc -c [file.hs]
copy
Specify output name
$ ghc -o [program] [file.hs]
copy
Enable all warnings
$ ghc -Wall [file.hs]
copy

SYNOPSIS

ghc [options] files

DESCRIPTION

ghc (Glasgow Haskell Compiler) is the leading compiler for the Haskell programming language. It compiles Haskell source code to native machine code, producing efficient executables.
GHC supports the full Haskell language standard plus numerous extensions for advanced type system features, parallelism, and performance. The --make mode automatically handles module dependencies.

PARAMETERS

FILES

Haskell source files (.hs, .lhs).
-o FILE
Output file name.
-c
Compile to object file only.
-O, -O2
Enable optimization.
-Wall
Enable all warnings.
-Werror
Treat warnings as errors.
-i DIR
Add to import path.
-package PKG
Use specified package.
--make
Build program with dependencies.
--help
Display help information.

CAVEATS

Compilation can be memory-intensive. Large projects benefit from incremental builds. Extension flags vary by GHC version.

HISTORY

GHC was started at the University of Glasgow in 1989. It has become the de facto standard Haskell compiler, actively developed by the Haskell community and industrial users.

SEE ALSO

ghci(1), cabal(1), stack(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community