Skip to content

Commit c158bd2

Browse files
Add GHC-02550 documentation
1 parent cc1f169 commit c158bd2

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{-# LANGUAGE QuantifiedConstraints #-}
2+
{-# LANGUAGE TypeFamilies #-}
3+
4+
module QuantifiedFunction where
5+
6+
import Data.Kind
7+
8+
class C a where
9+
10+
class A a where
11+
12+
f :: (C Int => A Int) => ()
13+
f = ()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{-# LANGUAGE QuantifiedConstraints #-}
2+
{-# LANGUAGE TypeFamilies #-}
3+
4+
module QuantifiedFunction where
5+
6+
import Data.Kind
7+
8+
class C a where
9+
10+
type family A :: k -> Constraint
11+
12+
f :: (C Int => A Int) => ()
13+
f = ()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Bad quantified constraint in function type
3+
---
4+
5+
In this example, a quantified constraint occurs in the type of a binding.
6+
Because the head of the quantified constraint is computed from a type family, we
7+
get the following error message:
8+
9+
```
10+
• Quantified predicate must have a class or type variable head:
11+
a => A a
12+
• In the quantified constraint ‘a => A a’
13+
In the type signature: f :: (a => A a) => ()
14+
```
15+
16+
One potential fix for this is to convert the type family into a class.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: Quantified predicate must have a class or type variable head
3+
summary: The head of a quantified constraint must be either a class or a type variable
4+
severity: error
5+
introduced: 9.4.1
6+
---
7+
8+
Quantified constraints are constraints which have their own constraints. The
9+
*head* of a quantified constraint is the constraint on the right side of the
10+
`=>` operator. For example, the head of the quantified constraint `Ord a => Eq
11+
a` is `Eq a`. This error message states that the head of a quantified constraint
12+
must not be a constraint resulting from, for example, a type family; it must
13+
be either a class constraint or a type variable.

0 commit comments

Comments
 (0)