Skip to content
Snippets Groups Projects
Commit 24a0e442 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Make sure that Constraint is unrelated to other kinds in tcIsSubKind

This was causing the bug reported in Trac #7697
parent 2bdc4fdc
No related branches found
No related tags found
No related merge requests found
......@@ -239,30 +239,35 @@ isSubKindCon kc1 kc2
| isOpenTypeKindCon kc2 = isSubOpenTypeKindCon kc1
| isConstraintKindCon kc1 = isLiftedTypeKindCon kc2
| isLiftedTypeKindCon kc1 = isConstraintKindCon kc2
| otherwise = False
-- See Note [Kind Constraint and kind *]
| otherwise = False
-------------------------
-- Hack alert: we need a tiny variant for the typechecker
-- Reason: f :: Int -> (a~b)
-- g :: forall (c::Constraint). Int -> c
-- h :: Int => Int
-- We want to reject these, even though Constraint is
-- a sub-kind of OpenTypeKind. It must be a sub-kind of OpenTypeKind
-- *after* the typechecker
-- a) So that (Ord a -> Eq a) is a legal type
-- b) So that the simplifer can generate (error (Eq a) "urk")
-- Moreover, after the type checker, Constraint and *
-- are identical; see Note [Kind Constraint and kind *]
--
-- Easiest way to reject is simply to make Constraint not
-- Easiest way to reject is simply to make Constraint a compliete
-- below OpenTypeKind when type checking
tcIsSubKind :: Kind -> Kind -> Bool
tcIsSubKind k1 k2
| isConstraintKind k1 = isConstraintKind k2
| isConstraintKind k2 = isConstraintKind k1
| otherwise = isSubKind k1 k2
tcIsSubKindCon :: TyCon -> TyCon -> Bool
tcIsSubKindCon kc1 kc2
| isConstraintKindCon kc1 = isConstraintKindCon kc2
| isConstraintKindCon kc2 = isConstraintKindCon kc1
| otherwise = isSubKindCon kc1 kc2
-------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment