Skip to content

The users' guide explanation of the KindSignatures extension is wrong

Summary

The description of the KindSignatures extension in GHC users' guide at

http://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/kind_signatures.html

provides a bulleted list of examples of adding a kind signature to a type variable, followed by another one where it's applied to a type constructor. It's easy to miss the last example. The section ends by claiming that the parentheses are required, when this is not the case. Both these examples are valid:

type MyKindedInt = Int :: *
type MyKindedIntList = [Int :: *]

Finally, and most disturbingly, test T12850.hs in GHC test suite demonstrates that KindSignatures also enables the single-quote syntax which I thought was activated by the DataKinds extension:

{-# LANGUAGE KindSignatures, NoDataKinds #-}
module T12850 where

import GHC.Types (RuntimeRep(IntRep), TYPE)

f :: (x :: TYPE 'IntRep) -> x
f x = x

It seems the border between the two extensions is not at the syntactic level, as implied by the users' guide. This should be either fixed or clarified in the documentation.

Proposed improvements or changes

  1. Explain up front that KindSignatures allows a kind signature to be applied to any type and to any type variable in a declaration left-hand side, much like a type signature can be applied to any expression or pattern variable.

  2. Fix the syntax - the extension doesn't require parentheses, from what I infer it instead adds another production to types with an optional kind signature.

  3. I hope the TYPE 'IntRep syntax is a bug in GHC rather than a mistake in documentation.

Environment

  • GHC version used (if appropriate): 9.2.1
Edited by Mario
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information