summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2013-06-11 09:49:20 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2013-06-11 09:49:20 +0100
commit6ecfa98d7b9860ccf29359d0bb3d6fda1d7c7335 (patch)
tree618dbe8e3d5daeb596c57568785f1102c054eb77
parentfc927b3dbda01f564398c0a47ad525a9ee118ee7 (diff)
downloadhaskell-6ecfa98d7b9860ccf29359d0bb3d6fda1d7c7335.tar.gz
Actually make the change described in 'Fix egregious typo in cmpTypeX'
I reverted it to try something else and forgot to put it back! Fixes Trac #7272 (again!).
-rw-r--r--compiler/types/Kind.lhs30
-rw-r--r--compiler/types/Type.lhs14
2 files changed, 20 insertions, 24 deletions
diff --git a/compiler/types/Kind.lhs b/compiler/types/Kind.lhs
index a37e4859ae..ff0ad013ab 100644
--- a/compiler/types/Kind.lhs
+++ b/compiler/types/Kind.lhs
@@ -40,7 +40,7 @@ module Kind (
isAnyKind, isAnyKindCon,
okArrowArgKind, okArrowResultKind,
- isSubOpenTypeKind,
+ isSubOpenTypeKind, isSubOpenTypeKindKey,
isSubKind, isSubKindCon,
tcIsSubKind, tcIsSubKindCon,
defaultKind, defaultKind_maybe,
@@ -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
@@ -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
diff --git a/compiler/types/Type.lhs b/compiler/types/Type.lhs
index 91991d66b9..993507062d 100644
--- a/compiler/types/Type.lhs
+++ b/compiler/types/Type.lhs
@@ -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 (
@@ -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
@@ -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
@@ -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]