Skip to content

Commit

Permalink
Actually make the change described in 'Fix egregious typo in cmpTypeX'
Browse files Browse the repository at this point in the history
I reverted it to try something else and forgot to put it back!
Fixes Trac #7272 (again!).
  • Loading branch information
Simon Peyton Jones committed Jun 11, 2013
1 parent fc927b3 commit 6ecfa98
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
30 changes: 14 additions & 16 deletions compiler/types/Kind.lhs
Expand Up @@ -40,7 +40,7 @@ module Kind (
isAnyKind, isAnyKindCon,
okArrowArgKind, okArrowResultKind,
isSubOpenTypeKind,
isSubOpenTypeKind, isSubOpenTypeKindKey,
isSubKind, isSubKindCon,
tcIsSubKind, tcIsSubKindCon,
defaultKind, defaultKind_maybe,
Expand Down Expand Up @@ -173,13 +173,8 @@ returnsConstraintKind _ = False
-- arg -> res
okArrowArgKindCon, okArrowResultKindCon :: TyCon -> Bool
okArrowArgKindCon kc
| isLiftedTypeKindCon kc = True
| isUnliftedTypeKindCon kc = True
| isConstraintKindCon kc = True
| otherwise = False
okArrowResultKindCon = okArrowArgKindCon
okArrowArgKindCon = isSubOpenTypeKindCon
okArrowResultKindCon = isSubOpenTypeKindCon
okArrowArgKind, okArrowResultKind :: Kind -> Bool
okArrowArgKind (TyConApp kc []) = okArrowArgKindCon kc
Expand All @@ -199,14 +194,17 @@ isSubOpenTypeKind :: Kind -> Bool
isSubOpenTypeKind (TyConApp kc []) = isSubOpenTypeKindCon kc
isSubOpenTypeKind _ = False
isSubOpenTypeKindCon kc
= isOpenTypeKindCon kc
|| isUnliftedTypeKindCon kc
|| isLiftedTypeKindCon kc
|| isConstraintKindCon kc -- Needed for error (Num a) "blah"
-- and so that (Ord a -> Eq a) is well-kinded
-- and so that (# Eq a, Ord b #) is well-kinded
-- See Note [Kind Constraint and kind *]
isSubOpenTypeKindCon kc = isSubOpenTypeKindKey (tyConUnique kc)
isSubOpenTypeKindKey :: Unique -> Bool
isSubOpenTypeKindKey uniq
= uniq == openTypeKindTyConKey
|| uniq == unliftedTypeKindTyConKey
|| uniq == liftedTypeKindTyConKey
|| uniq == constraintKindTyConKey -- Needed for error (Num a) "blah"
-- and so that (Ord a -> Eq a) is well-kinded
-- and so that (# Eq a, Ord b #) is well-kinded
-- See Note [Kind Constraint and kind *]
-- | Is this a kind (i.e. a type-of-types)?
isKind :: Kind -> Bool
Expand Down
14 changes: 6 additions & 8 deletions compiler/types/Type.lhs
Expand Up @@ -6,7 +6,7 @@
Type - public interface

\begin{code}
{-# OPTIONS_GHC -fno-warn-orphans -w #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- | Main functions for manipulating types and type-related things
module Type (
Expand Down Expand Up @@ -160,7 +160,7 @@ import TyCon
import TysPrim
import {-# SOURCE #-} TysWiredIn ( eqTyCon, typeNatKind, typeSymbolKind )
import PrelNames ( eqTyConKey, ipClassNameKey, openTypeKindTyConKey,
constraintKindTyConKey, liftedTypeKindTyConKey, unliftedTypeKindTyConKey )
constraintKindTyConKey, liftedTypeKindTyConKey )
import CoAxiom
-- others
Expand Down Expand Up @@ -1216,7 +1216,7 @@ cmpTypeX env t1 t2 | Just t1' <- coreView t1 = cmpTypeX env t1' t2
-- So the RHS has a data type
cmpTypeX env (TyVarTy tv1) (TyVarTy tv2) = rnOccL env tv1 `compare` rnOccR env tv2
cmpTypeX env (ForAllTy tv1 t1) (ForAllTy tv2 t2) = cmpTypeX env (tyVarKind tv1) (tyVarKind tv1)
cmpTypeX env (ForAllTy tv1 t1) (ForAllTy tv2 t2) = cmpTypeX env (tyVarKind tv1) (tyVarKind tv2)
`thenCmp` cmpTypeX (rnBndr2 env tv1 tv2) t1 t2
cmpTypeX env (AppTy s1 t1) (AppTy s2 t2) = cmpTypeX env s1 s2 `thenCmp` cmpTypeX env t1 t2
cmpTypeX env (FunTy s1 t1) (FunTy s2 t2) = cmpTypeX env s1 s2 `thenCmp` cmpTypeX env t1 t2
Expand Down Expand Up @@ -1261,16 +1261,14 @@ cmpTc :: TyCon -> TyCon -> Ordering
-- Also we treat OpenTypeKind as equal to either * or #
-- See Note [Comparison with OpenTypeKind]
cmpTc tc1 tc2
-- | u1 == openTypeKindTyConKey, is_type nu2 = EQ
-- | u2 == openTypeKindTyConKey, is_type nu1 = EQ
| otherwise = nu1 `compare` nu2
| u1 == openTypeKindTyConKey, isSubOpenTypeKindKey u2 = EQ
| u2 == openTypeKindTyConKey, isSubOpenTypeKindKey u1 = EQ
| otherwise = nu1 `compare` nu2
where
u1 = tyConUnique tc1
nu1 = if u1==constraintKindTyConKey then liftedTypeKindTyConKey else u1
u2 = tyConUnique tc2
nu2 = if u2==constraintKindTyConKey then liftedTypeKindTyConKey else u2
is_type u = u == liftedTypeKindTyConKey || u == unliftedTypeKindTyConKey
\end{code}

Note [Comparison with OpenTypeKind]
Expand Down

0 comments on commit 6ecfa98

Please sign in to comment.