diff --git a/message-index/messages/GHC-45510/index.md b/message-index/messages/GHC-45510/index.md new file mode 100644 index 00000000..67e491be --- /dev/null +++ b/message-index/messages/GHC-45510/index.md @@ -0,0 +1,19 @@ +--- +title: Term variables cannot be used here +summary: A variable defined at the level of terms cannot be directly used in type or kind signatures +severity: error +introduced: 9.10.1 +--- + +Through using [`RequiredTypeArguments`], Haskell gets support for programming with Dependent Types. +As such, the variables at the level of terms exist at the level of types. + +If you mistakenly refer to an entity that already exists as a term in your kind signature, you will get +an error about the fact that we cannot do such a thing. + +In the example, the `id` function is already exposed by the Prelude, but it is also a very convenient name to label identifiers. + +You can make sure that GHC understands you're declaring a type-level variable by using the [`forall`] keyword. + +[`RequiredTypeArguments`]: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/required_type_arguments.html +[`forall`]: https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/explicit_forall.html#extension-ExplicitForAll diff --git a/message-index/messages/GHC-45510/wrong-usage/after/WrongUsage.hs b/message-index/messages/GHC-45510/wrong-usage/after/WrongUsage.hs new file mode 100644 index 00000000..49e27edf --- /dev/null +++ b/message-index/messages/GHC-45510/wrong-usage/after/WrongUsage.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE RequiredTypeArguments #-} + +module ProperUsage where + +import Data.Kind (Type) + +data Set (cxt :: forall id. id -> Type) a = Set [a] diff --git a/message-index/messages/GHC-45510/wrong-usage/before/WrongUsage.hs b/message-index/messages/GHC-45510/wrong-usage/before/WrongUsage.hs new file mode 100644 index 00000000..7a3e60fb --- /dev/null +++ b/message-index/messages/GHC-45510/wrong-usage/before/WrongUsage.hs @@ -0,0 +1,7 @@ +{-# LANGUAGE RequiredTypeArguments #-} + +module WrongUsage where + +import Data.Kind (Type) + +data Set (cxt :: id -> Type) a = Set [a] diff --git a/message-index/messages/GHC-45510/wrong-usage/index.md b/message-index/messages/GHC-45510/wrong-usage/index.md new file mode 100644 index 00000000..183cd073 --- /dev/null +++ b/message-index/messages/GHC-45510/wrong-usage/index.md @@ -0,0 +1,3 @@ +--- +title: Explicit quantification of the type variable +---