Commit 18c7aea0 authored by dreixel's avatar dreixel

Rename ? to OpenKind and ?? to ArgKind

The previous names were not informative at all, and now we have
named kinds like Constraint and datatype promotion to kind, so
we might as well name these too.

I tried to update some comments to the new names, but certainly
many references to the old names remain.
parent 5e5d2bae
...@@ -303,10 +303,10 @@ constraintKindTyCon = mkKindTyCon constraintKindTyConName tySuperKind ...@@ -303,10 +303,10 @@ constraintKindTyCon = mkKindTyCon constraintKindTyConName tySuperKind
tySuperKindTyConName = mkPrimTyConName (fsLit "BOX") tySuperKindTyConKey tySuperKindTyCon tySuperKindTyConName = mkPrimTyConName (fsLit "BOX") tySuperKindTyConKey tySuperKindTyCon
anyKindTyConName = mkPrimTyConName (fsLit "AnyK") anyKindTyConKey anyKindTyCon anyKindTyConName = mkPrimTyConName (fsLit "AnyK") anyKindTyConKey anyKindTyCon
liftedTypeKindTyConName = mkPrimTyConName (fsLit "*") liftedTypeKindTyConKey liftedTypeKindTyCon liftedTypeKindTyConName = mkPrimTyConName (fsLit "*") liftedTypeKindTyConKey liftedTypeKindTyCon
openTypeKindTyConName = mkPrimTyConName (fsLit "?") openTypeKindTyConKey openTypeKindTyCon openTypeKindTyConName = mkPrimTyConName (fsLit "OpenKind") openTypeKindTyConKey openTypeKindTyCon
unliftedTypeKindTyConName = mkPrimTyConName (fsLit "#") unliftedTypeKindTyConKey unliftedTypeKindTyCon unliftedTypeKindTyConName = mkPrimTyConName (fsLit "#") unliftedTypeKindTyConKey unliftedTypeKindTyCon
ubxTupleKindTyConName = mkPrimTyConName (fsLit "(#)") ubxTupleKindTyConKey ubxTupleKindTyCon ubxTupleKindTyConName = mkPrimTyConName (fsLit "(#)") ubxTupleKindTyConKey ubxTupleKindTyCon
argTypeKindTyConName = mkPrimTyConName (fsLit "??") argTypeKindTyConKey argTypeKindTyCon argTypeKindTyConName = mkPrimTyConName (fsLit "ArgKind") argTypeKindTyConKey argTypeKindTyCon
constraintKindTyConName = mkPrimTyConName (fsLit "Constraint") constraintKindTyConKey constraintKindTyCon constraintKindTyConName = mkPrimTyConName (fsLit "Constraint") constraintKindTyConKey constraintKindTyCon
mkPrimTyConName :: FastString -> Unique -> TyCon -> Name mkPrimTyConName :: FastString -> Unique -> TyCon -> Name
......
...@@ -486,7 +486,7 @@ Note [Kind errors] ...@@ -486,7 +486,7 @@ Note [Kind errors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider the wanted problem: Consider the wanted problem:
alpha ~ (# Int, Int #) alpha ~ (# Int, Int #)
where alpha :: ?? and (# Int, Int #) :: (#). We can't spontaneously solve this constraint, where alpha :: ArgKind and (# Int, Int #) :: (#). We can't spontaneously solve this constraint,
but we should rather reject the program that give rise to it. If 'trySpontaneousEqTwoWay' but we should rather reject the program that give rise to it. If 'trySpontaneousEqTwoWay'
simply returns @CantSolve@ then that wanted constraint is going to propagate all the way and simply returns @CantSolve@ then that wanted constraint is going to propagate all the way and
get quantified over in inference mode. That's bad because we do know at this point that the get quantified over in inference mode. That's bad because we do know at this point that the
......
...@@ -1210,11 +1210,11 @@ in the cache! ...@@ -1210,11 +1210,11 @@ in the cache!
------------------ ------------------
defaultTyVar :: TcsUntouchables -> TcTyVar -> TcS Cts defaultTyVar :: TcsUntouchables -> TcTyVar -> TcS Cts
-- defaultTyVar is used on any un-instantiated meta type variables to -- defaultTyVar is used on any un-instantiated meta type variables to
-- default the kind of ? and ?? etc to *. This is important to ensure -- default the kind of OpenKind and ArgKind etc to *. This is important to
-- that instance declarations match. For example consider -- ensure that instance declarations match. For example consider
-- instance Show (a->b) -- instance Show (a->b)
-- foo x = show (\_ -> True) -- foo x = show (\_ -> True)
-- Then we'll get a constraint (Show (p ->q)) where p has argTypeKind (printed ??), -- Then we'll get a constraint (Show (p ->q)) where p has kind ArgKind,
-- and that won't match the typeKind (*) in the instance decl. -- and that won't match the typeKind (*) in the instance decl.
-- See test tc217. -- See test tc217.
-- --
......
...@@ -272,7 +272,7 @@ tcIsSubKindCon kc1 kc2 ...@@ -272,7 +272,7 @@ tcIsSubKindCon kc1 kc2
| otherwise = isSubKindCon kc1 kc2 | otherwise = isSubKindCon kc1 kc2
defaultKind :: Kind -> Kind defaultKind :: Kind -> Kind
-- ^ Used when generalising: default kind ? and ?? to *. -- ^ Used when generalising: default OpenKind and ArgKind to *.
-- See "Type#kind_subtyping" for more information on what that means -- See "Type#kind_subtyping" for more information on what that means
-- When we generalise, we make generic type variables whose kind is -- When we generalise, we make generic type variables whose kind is
...@@ -283,7 +283,7 @@ defaultKind :: Kind -> Kind ...@@ -283,7 +283,7 @@ defaultKind :: Kind -> Kind
-- We want f to get type -- We want f to get type
-- f :: forall (a::*). a -> Bool -- f :: forall (a::*). a -> Bool
-- Not -- Not
-- f :: forall (a::??). a -> Bool -- f :: forall (a::ArgKind). a -> Bool
-- because that would allow a call like (f 3#) as well as (f True), -- because that would allow a call like (f 3#) as well as (f True),
-- and the calling conventions differ. -- and the calling conventions differ.
-- This defaulting is done in TcMType.zonkTcTyVarBndr. -- This defaulting is done in TcMType.zonkTcTyVarBndr.
......
...@@ -1510,34 +1510,10 @@ cloneTyVarBndr (TvSubst in_scope tv_env) tv uniq ...@@ -1510,34 +1510,10 @@ cloneTyVarBndr (TvSubst in_scope tv_env) tv uniq
Kinds Kinds
~~~~~ ~~~~~
\begin{code} For the description of subkinding in GHC, see
-- $kind_subtyping http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/TypeType#Kinds
-- #kind_subtyping#
-- There's a little subtyping at the kind level:
--
-- @
-- ?
-- \/ \
-- \/ \
-- ?? (\#)
-- \/ \
-- \* \#
-- .
-- Where: \* [LiftedTypeKind] means boxed type
-- \# [UnliftedTypeKind] means unboxed type
-- (\#) [UbxTupleKind] means unboxed tuple
-- ?? [ArgTypeKind] is the lub of {\*, \#}
-- ? [OpenTypeKind] means any type at all
-- @
--
-- In particular:
--
-- > error :: forall a:?. String -> a
-- > (->) :: ?? -> ? -> \*
-- > (\\(x::t) -> ...)
--
-- Where in the last example @t :: ??@ (i.e. is not an unboxed tuple)
\begin{code}
type MetaKindVar = TyVar -- invariant: MetaKindVar will always be a type MetaKindVar = TyVar -- invariant: MetaKindVar will always be a
-- TcTyVar with details MetaTv TauTv ... -- TcTyVar with details MetaTv TauTv ...
-- meta kind var constructors and functions are in TcType -- meta kind var constructors and functions are in TcType
......
...@@ -620,9 +620,9 @@ pprTcApp _ pp tc [ty] ...@@ -620,9 +620,9 @@ pprTcApp _ pp tc [ty]
| tc `hasKey` parrTyConKey = ptext (sLit "[:") <> pp TopPrec ty <> ptext (sLit ":]") | tc `hasKey` parrTyConKey = ptext (sLit "[:") <> pp TopPrec ty <> ptext (sLit ":]")
| tc `hasKey` liftedTypeKindTyConKey = ptext (sLit "*") | tc `hasKey` liftedTypeKindTyConKey = ptext (sLit "*")
| tc `hasKey` unliftedTypeKindTyConKey = ptext (sLit "#") | tc `hasKey` unliftedTypeKindTyConKey = ptext (sLit "#")
| tc `hasKey` openTypeKindTyConKey = ptext (sLit "(?)") | tc `hasKey` openTypeKindTyConKey = ptext (sLit "OpenKind")
| tc `hasKey` ubxTupleKindTyConKey = ptext (sLit "(#)") | tc `hasKey` ubxTupleKindTyConKey = ptext (sLit "(#)")
| tc `hasKey` argTypeKindTyConKey = ptext (sLit "??") | tc `hasKey` argTypeKindTyConKey = ptext (sLit "ArgKind")
| Just n <- tyConIP_maybe tc = ppr n <> ptext (sLit "::") <> pp TopPrec ty | Just n <- tyConIP_maybe tc = ppr n <> ptext (sLit "::") <> pp TopPrec ty
pprTcApp p pp tc tys pprTcApp p pp tc tys
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment