Chapter 7. GHC Language Features
Prev |  | Next

# Chapter 7. GHC Language Features

As with all known Haskell systems, GHC implements some extensions to the language. They can all be enabled or disabled by command line flags or language pragmas. By default GHC understands the most recent Haskell version it supports, plus a handful of extensions.

Some of the Glasgow extensions serve to give you access to the underlying facilities with which we implement Haskell. Thus, you can get at the Raw Iron, if you are willing to write some non-portable code at a more primitive level. You need not be “stuck” on performance because of the implementation costs of Haskell's “high-level” features—you can always code “under” them. In an extreme case, you can write all your time-critical code in C, and then just glue it together with Haskell!

Before you get too carried away working at the lowest level (e.g., sloshing `MutableByteArray#`s around your program), you may wish to check if there are libraries that provide a “Haskellised veneer” over the features you want. The separate libraries documentation describes all the libraries that come with GHC.

## 7.1. Language options

The language option flags control what variation of the language are permitted.

Language options can be controlled in two ways:

- Every language option can switched on by a command-line flag "`-X...`" (e.g. `-XTemplateHaskell`), and switched off by the flag "`-XNo...`"; (e.g. `-XNoTemplateHaskell`).

- Language options recognised by Cabal can also be enabled using the `LANGUAGE` pragma, thus `{-# LANGUAGE TemplateHaskell #-}` (see Section 7.22.1, “LANGUAGE pragma”).

The flag `-fglasgow-exts` is equivalent to enabling the following extensions: `-XConstrainedClassMethods`, `-XDeriveDataTypeable`, `-XDeriveFoldable`, `-XDeriveFunctor`, `-XDeriveGeneric`, `-XDeriveTraversable`, `-XEmptyDataDecls`, `-XExistentialQuantification`, `-XExplicitNamespaces`, `-XFlexibleContexts`, `-XFlexibleInstances`, `-XForeignFunctionInterface`, `-XFunctionalDependencies`, `-XGeneralizedNewtypeDeriving`, `-XImplicitParams`, `-XKindSignatures`, `-XLiberalTypeSynonyms`, `-XMagicHash`, `-XMultiParamTypeClasses`, `-XParallelListComp`, `-XPatternGuards`, `-XPostfixOperators`, `-XRankNTypes`, `-XRecursiveDo`, `-XScopedTypeVariables`, `-XStandaloneDeriving`, `-XTypeOperators`, `-XTypeSynonymInstances`, `-XUnboxedTuples`, `-XUnicodeSyntax`, `-XUnliftedFFITypes`. Enabling these options is the only effect of `-fglasgow-exts`. We are trying to move away from this portmanteau flag, and towards enabling features individually.

Prev |  | Next
6.4. Thriftier: producing a program that gobbles less heap space | Home | 7.2. Unboxed types and primitive operations