HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleghc-9.10.3GHC2021

GHC.Types.Hint

  • 9 types
  • 10 values
  • Packageghc-9.10.3
  • Exports19
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceHint.hs
datadata GhcHint
#

A type for hints emitted by GHC. A hint suggests a possible way to deal with a particular warning or error.

Constructors

Instances1Outputable

An InstantiationSuggestion for a '.hsig' file. This is generated by GHC in case of a DriverUnexpectedSignature and suggests a way to instantiate a particular signature, where the first argument is the signature name and the second is the module where the signature was defined. Example:

src/MyStr.hsig:2:11: error: Unexpected signature: ‘MyStr’ (Try passing -instantiated-with="MyStr=MyStr" replacing MyStr as necessary.)

Constructors

  • SuggestSingleExtension !SDoc !Extension

    Suggest to enable the input extension. This is the hint that GHC emits if this is not a "known" fix, i.e. this is GHC giving its best guess on what extension might be necessary to make a certain program compile. For example, GHC might suggests to enable BlockArguments when the user simply formatted incorrectly the input program, so GHC here is trying to be as helpful as possible. If the input SDoc is not empty, it will contain some extra information about the why the extension is required, but it's totally irrelevant/redundant for IDEs and other tools.

  • SuggestAnyExtension !SDoc [Extension]

    Suggest to enable the input extensions. The list is to be intended as disjunctive i.e. the user is suggested to enable any of the extensions listed. If the input SDoc is not empty, it will contain some extra information about the why the extensions are required, but it's totally irrelevant/redundant for IDEs and other tools.

  • SuggestExtensions !SDoc [Extension]

    Suggest to enable the input extensions. The list is to be intended as conjunctive i.e. the user is suggested to enable all the extensions listed. If the input SDoc is not empty, it will contain some extra information about the why the extensions are required, but it's totally irrelevant/redundant for IDEs and other tools.

  • SuggestExtensionInOrderTo !SDoc !Extension

    Suggest to enable the input extension in order to fix a certain problem. This is the suggestion that GHC emits when is more-or-less clear "what's going on". For example, if both DeriveAnyClass and GeneralizedNewtypeDeriving are turned on, the right thing to do is to enabled DerivingStrategies, so in contrast to SuggestSingleExtension GHC will be a bit more "imperative" (i.e. "Use X Y Z in order to ... "). If the input SDoc is not empty, it will contain some extra information about the why the extensions are required, but it's totally irrelevant/redundant for IDEs and other tools.

datadata ImportSuggestion
#

Suggest how to fix an import.

Constructors

Whether a constructor name is printed out as a bare symbol, e.g. :.

True for symbolic names in infix position.

Used for pretty-printing.

Display info about the treatment of * under NoStarIsType.

With StarIsType, three properties of * hold:

(a) it is not an infix operator (b) it is always in scope (c) it is a synonym for Data.Kind.Type

However, the user might not know that they are working on a module with NoStarIsType and write code that still assumes (a), (b), and (c), which actually do not hold in that module.

Violation of (a) shows up in the parser. For instance, in the following examples, we have * not applied to enough arguments:

data A :: * data F :: * -> *

Violation of (b) or (c) show up in the renamer and the typechecker respectively. For instance:

type K = Either * Bool

This will parse differently depending on whether StarIsType is enabled, but it will parse nonetheless. With NoStarIsType it is parsed as a type operator, thus we have ((*) Either Bool). Now there are two cases to consider:

  1. There is no definition of (*) in scope. In this case the renamer will fail to look it up. This is a violation of assumption (b).

  2. There is a definition of the (*) type operator in scope (for example coming from GHC.TypeNats). In this case the user will get a kind mismatch error. This is a violation of assumption (c).

The user might unknowingly be working on a module with NoStarIsType or use * as Type out of habit. So it is important to give a hint whenever an assumption about * is violated. Unfortunately, it is somewhat difficult to deal with (c), so we limit ourselves to (a) and (b).

noStarIsTypeHints returns appropriate hints to the user depending on the extensions enabled in the module and the name that triggered the error. That is, if we have NoStarIsType and the error is related to * or its Unicode variant, we will suggest using Type; otherwise we won't suggest anything.