File tree Expand file tree Collapse file tree 4 files changed +55
-0
lines changed
message-index/messages/GHC-02550 Expand file tree Collapse file tree 4 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 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 = ()
Original file line number Diff line number Diff line change 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 = ()
Original file line number Diff line number Diff line change 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.
Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments