Skip to content

Add GHC-02550 documentation #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 = ()
Original file line number Diff line number Diff line change
@@ -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 = ()
16 changes: 16 additions & 0 deletions message-index/messages/GHC-02550/example/index.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 14 additions & 0 deletions message-index/messages/GHC-02550/index.md
Original file line number Diff line number Diff line change
@@ -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.