File: control.rst

package info (click to toggle)
ghc 9.10.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 169,076 kB
  • sloc: haskell: 713,554; ansic: 84,184; cpp: 30,255; javascript: 9,003; sh: 7,870; fortran: 3,527; python: 3,228; asm: 2,523; makefile: 2,324; yacc: 1,570; lisp: 532; xml: 196; perl: 111; csh: 2
file content (264 lines) | stat: -rw-r--r-- 9,800 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
.. _options-language:

Controlling editions and extensions
-----------------------------------

.. index::
   single: language; option
   single: options; language
   single: extensions; options controlling
   single: editions; language

GHC supports multiple language editions: :extension:`Haskell98`,
:extension:`Haskell2010`, :extension:`GHC2021` and :extension:`GHC2024`.  Each
language edition consists of a collection of language extensions, and there are
many other language extensions not currently part of a language edition but that
can be enabled explicitly.

Currently, :extension:`GHC2021` is used by default if no other language edition
is explicitly requested, for backwards compatibility purposes. Since later
versions of GHC may use a different language edition by default, users are
advised to declare a language edition explicitly.  Using :extension:`GHC2024` is
recommended for new code.

A language edition can be selected:

-  at the package level, e.g. using ``default-language: GHC2024`` in a
   ``.cabal`` file;

-  with a command-line flag prefixed by "``-X...``" (e.g. ``-XGHC2024``); or

-  for an individual module using the :pragma:`LANGUAGE` pragma, e.g.
   ``{-# LANGUAGE GHC2024 #-}``.

Selecting a language edition overrides any previous selection. It is not
possible to disable a language edition.

Similarly, language extensions can be controlled (either enabled or disabled):

-  at the package level, e.g. using ``default-extensions: TemplateHaskell`` in a
   ``.cabal`` file;

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

-  for an individual module using the :pragma:`LANGUAGE` pragma, e.g.
   ``{-# LANGUAGE TemplateHaskell #-}`` or ``{-# LANGUAGE NoTemplateHaskell #-}``.

.. extension:: GHC2024
    :shortdesc: Use GHC’s set of default language extensions from 2024

    :since: 9.10.1

    GHC blesses a number of extensions, beyond Haskell 2010, to be suitable to
    turned on by default. These extensions are considered to be stable and
    conservative.

    Note that, because GHC2024 includes a number of non-standardized
    extensions, the stability guarantees it provides are not quite as strong as
    those provided by, e.g., :extension:`Haskell2010`. While GHC does take
    pains to avoid changing the semantics of these extensions, changes may
    still happen (e.g. the simplified subsumption change introduced in GHC 9.0
    which caused GHC to reject some programs using :extension:`RankNTypes`).

    The ``GHC2024`` language edition includes the following extensions:

    .. hlist::

     * :extension:`BangPatterns`
     * :extension:`BinaryLiterals`
     * :extension:`ConstrainedClassMethods`
     * :extension:`ConstraintKinds`
     * :extension:`DataKinds`
     * :extension:`DeriveDataTypeable`
     * :extension:`DeriveFoldable`
     * :extension:`DeriveFunctor`
     * :extension:`DeriveGeneric`
     * :extension:`DeriveLift`
     * :extension:`DeriveTraversable`
     * :extension:`DerivingStrategies`
     * :extension:`DisambiguateRecordFields`
     * :extension:`DoAndIfThenElse`
     * :extension:`EmptyCase`
     * :extension:`EmptyDataDecls`
     * :extension:`EmptyDataDeriving`
     * :extension:`ExistentialQuantification`
     * :extension:`ExplicitForAll`
     * :extension:`ExplicitNamespaces`
     * :extension:`FieldSelectors`
     * :extension:`FlexibleContexts`
     * :extension:`FlexibleInstances`
     * :extension:`ForeignFunctionInterface`
     * :extension:`GADTs`
     * :extension:`GADTSyntax`
     * :extension:`GeneralisedNewtypeDeriving`
     * :extension:`HexFloatLiterals`
     * :extension:`ImplicitPrelude`
     * :extension:`ImportQualifiedPost`
     * :extension:`InstanceSigs`
     * :extension:`KindSignatures`
     * :extension:`LambdaCase`
     * :extension:`MonoLocalBinds`
     * :extension:`MonomorphismRestriction`
     * :extension:`MultiParamTypeClasses`
     * :extension:`NamedFieldPuns`
     * :extension:`NamedWildCards`
     * :extension:`NumericUnderscores`
     * :extension:`PatternGuards`
     * :extension:`PolyKinds`
     * :extension:`PostfixOperators`
     * :extension:`RankNTypes`
     * :extension:`RelaxedPolyRec`
     * :extension:`RoleAnnotations`
     * :extension:`ScopedTypeVariables`
     * :extension:`StandaloneDeriving`
     * :extension:`StandaloneKindSignatures`
     * :extension:`StarIsType`
     * :extension:`TraditionalRecordSyntax`
     * :extension:`TupleSections`
     * :extension:`TypeApplications`
     * :extension:`TypeOperators`
     * :extension:`TypeSynonymInstances`

.. extension:: GHC2021
    :shortdesc: Use GHC’s set of default language extensions from 2021

    :since: 9.2.1

    See :extension:`GHC2024` for general comments about ``GHC20xx`` language
    editions.

    Also note that due to a `minor oversight
    <https://github.com/ghc-proposals/ghc-proposals/issues/551>`_, enabling
    this edition behaves slightly differently than enabling each of its
    constituent extensions. Specifically, while :extension:`TypeOperators` implies
    :extension:`ExplicitNamespaces`, :extension:`ExplicitNamespaces` is not included
    in :extension:`GHC2021`. Moreover, while :extension:`GADTs` is not part of
    :extension:`GHC2021`, the combination of :extension:`GADTSyntax` and
    :extension:`ExistentialQuantification` is enough to define and use GADTs.

    The ``GHC2021`` language edition includes the following extensions:

    .. hlist::

     * :extension:`BangPatterns`
     * :extension:`BinaryLiterals`
     * :extension:`ConstrainedClassMethods`
     * :extension:`ConstraintKinds`
     * :extension:`DeriveDataTypeable`
     * :extension:`DeriveFoldable`
     * :extension:`DeriveFunctor`
     * :extension:`DeriveGeneric`
     * :extension:`DeriveLift`
     * :extension:`DeriveTraversable`
     * :extension:`DoAndIfThenElse`
     * :extension:`EmptyCase`
     * :extension:`EmptyDataDecls`
     * :extension:`EmptyDataDeriving`
     * :extension:`ExistentialQuantification`
     * :extension:`ExplicitForAll`
     * :extension:`FieldSelectors`
     * :extension:`FlexibleContexts`
     * :extension:`FlexibleInstances`
     * :extension:`ForeignFunctionInterface`
     * :extension:`GADTSyntax`
     * :extension:`GeneralisedNewtypeDeriving`
     * :extension:`HexFloatLiterals`
     * :extension:`ImplicitPrelude`
     * :extension:`ImportQualifiedPost`
     * :extension:`InstanceSigs`
     * :extension:`KindSignatures`
     * :extension:`MonomorphismRestriction`
     * :extension:`MultiParamTypeClasses`
     * :extension:`NamedFieldPuns`
     * :extension:`NamedWildCards`
     * :extension:`NumericUnderscores`
     * :extension:`PatternGuards`
     * :extension:`PolyKinds`
     * :extension:`PostfixOperators`
     * :extension:`RankNTypes`
     * :extension:`RelaxedPolyRec`
     * :extension:`ScopedTypeVariables`
     * :extension:`StandaloneDeriving`
     * :extension:`StandaloneKindSignatures`
     * :extension:`StarIsType`
     * :extension:`TraditionalRecordSyntax`
     * :extension:`TupleSections`
     * :extension:`TypeApplications`
     * :extension:`TypeOperators`
     * :extension:`TypeSynonymInstances`
     * :extension:`NoExplicitNamespaces <ExplicitNamespaces>`


.. extension:: Haskell2010
    :shortdesc: Use the Haskell 2010 language edition.

    Compile using the Haskell 2010 language edition, as specified by the
    `Haskell 2010 report <https://www.haskell.org/onlinereport/haskell2010/>`_.
    GHC aims to behave mostly as a Haskell 2010 compiler, but there are a few
    known deviations from the standard (see :ref:`vs-Haskell-defn`).

    The ``Haskell2010`` language edition includes the following language extensions:

    .. hlist::

     * :extension:`CUSKs`
     * :extension:`DatatypeContexts`
     * :extension:`DeepSubsumption`
     * :extension:`DoAndIfThenElse`
     * :extension:`EmptyDataDecls`
     * :extension:`FieldSelectors`
     * :extension:`ForeignFunctionInterface`
     * :extension:`ImplicitPrelude`
     * :extension:`MonomorphismRestriction`
     * :extension:`PatternGuards`
     * :extension:`RelaxedPolyRec`
     * :extension:`StarIsType`
     * :extension:`TraditionalRecordSyntax`


.. extension:: Haskell98
    :shortdesc: Use the Haskell 98 language edition.

    Compile using the Haskell 98 language edition, as specified by the `Haskell
    98 report <https://www.haskell.org/onlinereport/>`_.  GHC aims to behave
    mostly as a Haskell 98 compiler, but there are a few known deviations from
    the standard (see :ref:`vs-Haskell-defn`).

    The ``Haskell98`` language edition includes the following language extensions:

    .. hlist::

     * :extension:`CUSKs`
     * :extension:`DatatypeContexts`
     * :extension:`DeepSubsumption`
     * :extension:`FieldSelectors`
     * :extension:`ImplicitPrelude`
     * :extension:`MonomorphismRestriction`
     * :extension:`NPlusKPatterns`
     * :extension:`NondecreasingIndentation`
     * :extension:`StarIsType`
     * :extension:`TraditionalRecordSyntax`



Although not recommended, the deprecated :ghc-flag:`-fglasgow-exts` flag enables
a large swath of the extensions supported by GHC at once.

.. ghc-flag:: -fglasgow-exts
    :shortdesc: Deprecated. Enable most language extensions;
        see :ref:`options-language` for exactly which ones.
    :type: dynamic
    :reverse: -fno-glasgow-exts
    :category: misc

    The flag ``-fglasgow-exts`` is equivalent to enabling the following extensions:

    .. include:: ../what_glasgow_exts_does.rst

    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.