<commit_before>.. _options-sanity:

Warnings and sanity-checking
----------------------------

.. index::
   single: sanity-checking options
   single: warnings

GHC has a number of options that select which types of non-fatal error
messages, otherwise known as warnings, can be generated during
compilation. By default, you get a standard set of warnings which are
generally likely to indicate bugs in your program. These are:

.. hlist::
    :columns: 3

    * :ghc-flag:`-Woverlapping-patterns`
    * :ghc-flag:`-Wwarnings-deprecations`
    * :ghc-flag:`-Wdeprecated-flags`
    * :ghc-flag:`-Wunrecognised-pragmas`
    * :ghc-flag:`-Wmissed-specialisations`
    * :ghc-flag:`-Wduplicate-constraints`
    * :ghc-flag:`-Wduplicate-exports`
    * :ghc-flag:`-Woverflowed-literals`
    * :ghc-flag:`-Wempty-enumerations`
    * :ghc-flag:`-Wmissing-fields`
    * :ghc-flag:`-Wmissing-methods`
    * :ghc-flag:`-Wwrong-do-bind`
    * :ghc-flag:`-Wunsupported-calling-conventions`
    * :ghc-flag:`-Wdodgy-foreign-imports`
    * :ghc-flag:`-Winline-rule-shadowing`
    * :ghc-flag:`-Wunsupported-llvm-version`
    * :ghc-flag:`-Wtabs`

The following flags are simple ways to select standard "packages" of warnings:

.. ghc-flag:: -W

    Provides the standard warnings plus :ghc-flag:`-Wunused-binds`,
    :ghc-flag:`-Wunused-matches`, :ghc-flag:`-Wunused-imports`,
    :ghc-flag:`-Wincomplete-patterns`, :ghc-flag:`-Wdodgy-exports`, and
    :ghc-flag:`-Wdodgy-imports`.

.. ghc-flag:: -Wall

    Turns on all warning options that indicate potentially suspicious
    code. The warnings that are *not* enabled by :ghc-flag:`-Wall` are
    :ghc-flag:`-Wincomplete-uni-patterns`,
    :ghc-flag:`-Wincomplete-record-updates`,
    :ghc-flag:`-Wmonomorphism-restriction`,
    :ghc-flag:`-Wimplicit-prelude`, :ghc-flag:`-Wmissing-local-sigs`,
    :ghc-flag:`-Wmissing-exported-sigs`, :ghc-flag:`-Wmissing-import-lists`
    and :ghc-flag:`-Widentities`.

.. ghc-flag:: -Wcompat

    Turns on warnings that will be enabled by default in the future, but remain
    off in normal compilations for the time being. This allows library authors
    eager to make their code future compatible to adapt to new features before
    they even generate warnings.

    This currently enables :ghc-flag:`-Wmissing-monadfail-instance`,
    :ghc-flag:`-Wsemigroup`, and :ghc-flag:`-Wnoncanonical-monoid-instances`.

.. ghc-flag:: -Wno-compat

    Disables all warnings enabled by :ghc-flag:`-Wcompat`.

.. ghc-flag:: -w

    Turns off all warnings, including the standard ones and those that
    :ghc-flag:`-Wall` doesn't enable.

.. ghc-flag:: -Werror

    Makes any warning into a fatal error. Useful so that you don't miss<commit_msg>user-guide: Reformat warning lists<commit_after>.. _options-sanity:

Warnings and sanity-checking
----------------------------

.. index::
   single: sanity-checking options
   single: warnings

GHC has a number of options that select which types of non-fatal error
messages, otherwise known as warnings, can be generated during
compilation. By default, you get a standard set of warnings which are
generally likely to indicate bugs in your program. These are:

.. hlist::
    :columns: 3

    * :ghc-flag:`-Woverlapping-patterns`
    * :ghc-flag:`-Wwarnings-deprecations`
    * :ghc-flag:`-Wdeprecated-flags`
    * :ghc-flag:`-Wunrecognised-pragmas`
    * :ghc-flag:`-Wmissed-specialisations`
    * :ghc-flag:`-Wduplicate-constraints`
    * :ghc-flag:`-Wduplicate-exports`
    * :ghc-flag:`-Woverflowed-literals`
    * :ghc-flag:`-Wempty-enumerations`
    * :ghc-flag:`-Wmissing-fields`
    * :ghc-flag:`-Wmissing-methods`
    * :ghc-flag:`-Wwrong-do-bind`
    * :ghc-flag:`-Wunsupported-calling-conventions`
    * :ghc-flag:`-Wdodgy-foreign-imports`
    * :ghc-flag:`-Winline-rule-shadowing`
    * :ghc-flag:`-Wunsupported-llvm-version`
    * :ghc-flag:`-Wtabs`

The following flags are simple ways to select standard "packages" of warnings:

.. ghc-flag:: -W

    Provides the standard warnings plus

    .. hlist::
        :columns: 3

        * :ghc-flag:`-Wunused-binds`
        * :ghc-flag:`-Wunused-matches`
        * :ghc-flag:`-Wunused-imports`
        * :ghc-flag:`-Wincomplete-patterns`
        * :ghc-flag:`-Wdodgy-exports`
        * :ghc-flag:`-Wdodgy-imports`

.. ghc-flag:: -Wall

    Turns on all warning options that indicate potentially suspicious
    code. The warnings that are *not* enabled by :ghc-flag:`-Wall` are

    .. hlist::
        :columns: 3

        * :ghc-flag:`-Wincomplete-uni-patterns`
        * :ghc-flag:`-Wincomplete-record-updates`
        * :ghc-flag:`-Wmonomorphism-restriction`
        * :ghc-flag:`-Wimplicit-prelude`
        * :ghc-flag:`-Wmissing-local-sigs`
        * :ghc-flag:`-Wmissing-exported-sigs`
        * :ghc-flag:`-Wmissing-import-lists`
        * :ghc-flag:`-Widentities`

.. ghc-flag:: -Wcompat

    Turns on warnings that will be enabled by default in the future, but remain
    off in normal compilations for the time being. This allows library authors
    eager to make their code future compatible to adapt to new features before
    they even generate warnings.

    This currently enables

    .. hlist::
        :columns: 3

        * :ghc-flag:`-Wmissing-monadfail-instance`
        * :ghc-flag:`-Wsemigroup`
        * :ghc-flag:`-Wnoncanonical-monoid-instances`

.. ghc-flag:: -Wno-compat

    Disables all warnings enabled by :ghc-flag:`-Wcompat`.

.. ghc-flag:: -w

    Turns off all warnings, including the standard ones and those that
    :ghc-flag:`-Wall` doesn't enable.

.. ghc-flag:: -Werror

    Makes any warning into a fatal error. Useful so that you don't miss
{'fraction_non_alphanumeric': 0.14743362831858406, 'fraction_numerical': 0.0008849557522123894, 'mean_word_length': 2.9851904090267984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '651984', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1919, 'n_words': 452}