diff --git a/message-index/messages/GHC-02550/example/after/QuantifiedFunction.hs b/message-index/messages/GHC-02550/example/after/QuantifiedFunction.hs new file mode 100644 index 00000000..2a9f60fd --- /dev/null +++ b/message-index/messages/GHC-02550/example/after/QuantifiedFunction.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE TypeFamilies #-} + +module QuantifiedFunction where + +import Data.Kind + +class C a where + +class A a where + +f :: (C Int => A Int) => () +f = () diff --git a/message-index/messages/GHC-02550/example/before/QuantifiedFunction.hs b/message-index/messages/GHC-02550/example/before/QuantifiedFunction.hs new file mode 100644 index 00000000..9a1b5fc2 --- /dev/null +++ b/message-index/messages/GHC-02550/example/before/QuantifiedFunction.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE TypeFamilies #-} + +module QuantifiedFunction where + +import Data.Kind + +class C a where + +type family A :: k -> Constraint + +f :: (C Int => A Int) => () +f = () diff --git a/message-index/messages/GHC-02550/example/index.md b/message-index/messages/GHC-02550/example/index.md new file mode 100644 index 00000000..cb406ec7 --- /dev/null +++ b/message-index/messages/GHC-02550/example/index.md @@ -0,0 +1,16 @@ +--- +title: Bad quantified constraint in function type +--- + +In this example, a quantified constraint occurs in the type of a binding. +Because the head of the quantified constraint is computed from a type family, we +get the following error message: + +``` +• Quantified predicate must have a class or type variable head: + a => A a +• In the quantified constraint ‘a => A a’ + In the type signature: f :: (a => A a) => () +``` + +One potential fix for this is to convert the type family into a class. diff --git a/message-index/messages/GHC-02550/index.md b/message-index/messages/GHC-02550/index.md new file mode 100644 index 00000000..c8b0aaa9 --- /dev/null +++ b/message-index/messages/GHC-02550/index.md @@ -0,0 +1,14 @@ +--- +title: Quantified predicate must have a class or type variable head +summary: The head of a quantified constraint must be either a class or a type variable +severity: error +introduced: 9.6.1 +--- + +[Quantified constraints](https://downloads.haskell.org/ghc/9.12.1/docs/users_guide/exts/quantified_constraints.html) +are constraints which have their own constraints. The +*head* of a quantified constraint is the constraint on the right side of the +`=>` operator. For example, the head of the quantified constraint `Ord a => Eq +a` is `Eq a`. This error message states that the head of a quantified constraint +must not be a constraint resulting from, for example, a type family; it must +be either a class constraint or a type variable.