diff options
391 files changed, 1870 insertions, 2002 deletions
diff --git a/.gitignore b/.gitignore index 270adffcd6..7e2425c964 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ __pycache__ log tags +TAGS autom4te.cache config.log diff --git a/.gitmodules b/.gitmodules index 2125a92ce3..e190730b77 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "libraries/binary"] path = libraries/binary - url = ../packages/binary.git + url = https://github.com/kolmodin/binary.git ignore = untracked [submodule "libraries/bytestring"] path = libraries/bytestring @@ -108,7 +108,7 @@ ignore = untracked [submodule "utils/haddock"] path = utils/haddock - url = ../haddock.git + url = https://github.com/int-index/haddock.git ignore = untracked branch = ghc-head [submodule "nofib"] diff --git a/compiler/basicTypes/DataCon.hs b/compiler/basicTypes/DataCon.hs index 6f0cf411b2..0e1bb01221 100644 --- a/compiler/basicTypes/DataCon.hs +++ b/compiler/basicTypes/DataCon.hs @@ -53,7 +53,7 @@ module DataCon ( isVanillaDataCon, classDataCon, dataConCannotMatch, dataConUserTyVarsArePermuted, isBanged, isMarkedStrict, eqHsBang, isSrcStrict, isSrcUnpacked, - specialPromotedDc, isLegacyPromotableDataCon, isLegacyPromotableTyCon, + specialPromotedDc, -- ** Promotion related functions promoteDataCon @@ -1324,26 +1324,6 @@ isVanillaDataCon dc = dcVanilla dc specialPromotedDc :: DataCon -> Bool specialPromotedDc = isKindTyCon . dataConTyCon --- | Was this datacon promotable before GHC 8.0? That is, is it promotable --- without -XTypeInType -isLegacyPromotableDataCon :: DataCon -> Bool -isLegacyPromotableDataCon dc - = null (dataConEqSpec dc) -- no GADTs - && null (dataConTheta dc) -- no context - && not (isFamInstTyCon (dataConTyCon dc)) -- no data instance constructors - && uniqSetAll isLegacyPromotableTyCon (tyConsOfType (dataConUserType dc)) - --- | Was this tycon promotable before GHC 8.0? That is, is it promotable --- without -XTypeInType -isLegacyPromotableTyCon :: TyCon -> Bool -isLegacyPromotableTyCon tc - = isVanillaAlgTyCon tc || - -- This returns True more often than it should, but it's quite painful - -- to make this fully accurate. And no harm is caused; we just don't - -- require -XTypeInType every time we need to. (We'll always require - -- -XDataKinds, though, so there's no standards-compliance issue.) - isFunTyCon tc || isKindTyCon tc - classDataCon :: Class -> DataCon classDataCon clas = case tyConDataCons (classTyCon clas) of (dict_constr:no_more) -> ASSERT( null no_more ) dict_constr diff --git a/compiler/basicTypes/Name.hs b/compiler/basicTypes/Name.hs index 8fa60a8f64..564e0e3db5 100644 --- a/compiler/basicTypes/Name.hs +++ b/compiler/basicTypes/Name.hs @@ -79,7 +79,6 @@ module Name ( import GhcPrelude import {-# SOURCE #-} TyCoRep( TyThing ) -import {-# SOURCE #-} PrelNames( starKindTyConKey, unicodeStarKindTyConKey ) import OccName import Module @@ -687,24 +686,6 @@ pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc pprInfixName n = pprInfixVar (isSymOcc (getOccName n)) (ppr n) pprPrefixName :: NamedThing a => a -> SDoc -pprPrefixName thing - | name `hasKey` starKindTyConKey || name `hasKey` unicodeStarKindTyConKey - = ppr name -- See Note [Special treatment for kind *] - | otherwise - = pprPrefixVar (isSymOcc (nameOccName name)) (ppr name) +pprPrefixName thing = pprPrefixVar (isSymOcc (nameOccName name)) (ppr name) where name = getName thing - -{- -Note [Special treatment for kind *] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Do not put parens around the kind '*'. Even though it looks like -an operator, it is really a special case. - -This pprPrefixName stuff is really only used when printing HsSyn, -which has to be polymorphic in the name type, and hence has to go via -the overloaded function pprPrefixOcc. It's easier where we know the -type being pretty printed; eg the pretty-printing code in TyCoRep. - -See Trac #7645, which led to this. --} diff --git a/compiler/basicTypes/RdrName.hs b/compiler/basicTypes/RdrName.hs index bc90dafa98..6dfc6babe8 100644 --- a/compiler/basicTypes/RdrName.hs +++ b/compiler/basicTypes/RdrName.hs @@ -34,8 +34,7 @@ module RdrName ( -- ** Destruction rdrNameOcc, rdrNameSpace, demoteRdrName, isRdrDataCon, isRdrTyVar, isRdrTc, isQual, isQual_maybe, isUnqual, - isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, isStar, - isUniStar, + isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName, -- * Local mapping of 'RdrName' to 'Name.Name' LocalRdrEnv, emptyLocalRdrEnv, extendLocalRdrEnv, extendLocalRdrEnvList, @@ -63,7 +62,10 @@ module RdrName ( pprNameProvenance, Parent(..), ImportSpec(..), ImpDeclSpec(..), ImpItemSpec(..), - importSpecLoc, importSpecModule, isExplicitItem, bestImport + importSpecLoc, importSpecModule, isExplicitItem, bestImport, + + -- * Utils for StarIsType + starInfo ) where #include "HsVersions.h" @@ -262,10 +264,6 @@ isExact_maybe :: RdrName -> Maybe Name isExact_maybe (Exact n) = Just n isExact_maybe _ = Nothing -isStar, isUniStar :: RdrName -> Bool -isStar = (fsLit "*" ==) . occNameFS . rdrNameOcc -isUniStar = (fsLit "★" ==) . occNameFS . rdrNameOcc - {- ************************************************************************ * * @@ -1277,3 +1275,87 @@ instance Outputable ImportSpec where pprLoc :: SrcSpan -> SDoc pprLoc (RealSrcSpan s) = text "at" <+> ppr s pprLoc (UnhelpfulSpan {}) = empty + +-- | Display info about the treatment of '*' under NoStarIsType. +-- +-- With StarIsType, three properties of '*' hold: +-- +-- (a) it is not an infix operator +-- (b) it is always in scope +-- (c) it is a synonym for Data.Kind.Type +-- +-- However, the user might not know that he's working on a module with +-- NoStarIsType and write code that still assumes (a), (b), and (c), which +-- actually do not hold in that module. +-- +-- Violation of (a) shows up in the parser. For instance, in the following +-- examples, we have '*' not applied to enough arguments: +-- +-- data A :: * +-- data F :: * -> * +-- +-- Violation of (b) or (c) show up in the renamer and the typechecker +-- respectively. For instance: +-- +-- type K = Either * Bool +-- +-- This will parse differently depending on whether StarIsType is enabled, +-- but it will parse nonetheless. With NoStarIsType it is parsed as a type +-- operator, thus we have ((*) Either Bool). Now there are two cases to +-- consider: +-- +-- 1. There is no definition of (*) in scope. In this case the renamer will +-- fail to look it up. This is a violation of assumption (b). +-- +-- 2. There is a definition of the (*) type operator in scope (for example +-- coming from GHC.TypeNats). In this case the user will get a kind +-- mismatch error. This is a violation of assumption (c). +-- +-- Since NoStarIsType is implied by a fairly common extension TypeOperators, +-- the user might be working on a module with NoStarIsType unbeknownst to him. +-- Even if the user switched off StarIsType manually, he might have forgotten +-- about it and use '*' as 'Data.Kind.Type' out of habit. +-- +-- Thus it is very important to give a hint whenever an assumption about '*' is +-- violated. Unfortunately, it is somewhat difficult to deal with (c), so we +-- limit ourselves to (a) and (b). +-- +-- 'starInfo' generates an appropriate hint to the user depending on the +-- extensions enabled in the module and the name that triggered the error. +-- That is, if we have NoStarIsType and the error is related to '*' or its +-- Unicode variant, the resulting SDoc will contain a helpful suggestion. +-- Otherwise it is empty. +-- +starInfo :: (Bool, Bool) -> RdrName -> SDoc +starInfo (type_operators, star_is_type) rdr_name = + -- One might ask: if can use sdocWithDynFlags here, why bother to take + -- (type_operators, star_is_type) as input? Why not refactor? + -- + -- The reason is that sdocWithDynFlags would provide DynFlags that are active + -- in the module that tries to load the problematic definition, not + -- in the module that is being loaded. + -- + -- So if we have 'data T :: *' in a module with NoStarIsType, then the hint + -- must be displayed even if we load this definition from a module (or GHCi) + -- with StarIsType enabled! + -- + if isUnqualStar && not star_is_type + then text "With NoStarIsType" <> + (if type_operators + then text " (implied by TypeOperators), " + else text ", ") <> + quotes (ppr rdr_name) <> + text " is treated as a regular type operator. " + $$ + text "Did you mean to use " <> quotes (text "Type") <> + text " from Data.Kind instead?" + else empty + where + -- Does rdr_name look like the user might have meant the '*' kind by it? + -- We focus on unqualified stars specifically, because qualified stars are + -- treated as type operators even under StarIsType. + isUnqualStar + | Unqual occName <- rdr_name + = let fs = occNameFS occName + in fs == fsLit "*" || fs == fsLit "★" + | otherwise = False diff --git a/compiler/basicTypes/SrcLoc.hs b/compiler/basicTypes/SrcLoc.hs index 5a0159e95f..eeba3d7be8 100644 --- a/compiler/basicTypes/SrcLoc.hs +++ b/compiler/basicTypes/SrcLoc.hs @@ -333,6 +333,7 @@ srcSpanFirstCharacter (RealSrcSpan span) = RealSrcSpan $ mkRealSrcSpan loc1 loc2 where loc1@(SrcLoc f l c) = realSrcSpanStart span loc2 = SrcLoc f l (c+1) + {- ************************************************************************ * * @@ -511,8 +512,8 @@ pprUserRealSpan show_path (RealSrcSpan' src_path sline scol eline ecol) data GenLocated l e = L l e deriving (Eq, Ord, Data, Functor, Foldable, Traversable) -type Located e = GenLocated SrcSpan e -type RealLocated e = GenLocated RealSrcSpan e +type Located = GenLocated SrcSpan +type RealLocated = GenLocated RealSrcSpan unLoc :: GenLocated l e -> e unLoc (L _ e) = e diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs index 8ec181c430..1e85ea133e 100644 --- a/compiler/deSugar/DsMeta.hs +++ b/compiler/deSugar/DsMeta.hs @@ -288,10 +288,8 @@ and have Template Haskell turn it into this: idProxy :: forall k proxy (b :: k). proxy b -> proxy b idProxy x = x -Notice that we explicitly quantified the variable `k`! This is quite bad, as the -latter declaration requires -XTypeInType, while the former does not. Not to -mention that the latter declaration isn't even what the user wrote in the -first place. +Notice that we explicitly quantified the variable `k`! The latter declaration +isn't what the user wrote in the first place. Usually, the culprit behind these bugs is taking implicitly quantified type variables (often from the hsib_vars field of HsImplicitBinders) and putting @@ -1128,6 +1126,7 @@ repTy (HsEqTy _ t1 t2) = do t2' <- repLTy t2 eq <- repTequality repTapps eq [t1', t2'] +repTy (HsStarTy _ _) = repTStar repTy (HsKindSig _ t k) = do t1 <- repLTy t k1 <- repLTy k diff --git a/compiler/hsSyn/Convert.hs b/compiler/hsSyn/Convert.hs index 7487983419..7b721ed1f2 100644 --- a/compiler/hsSyn/Convert.hs +++ b/compiler/hsSyn/Convert.hs @@ -963,7 +963,7 @@ the trees to reflect the fixities of the underlying operators: This is done by the renamer (see @mkOppAppRn@, @mkConOppPatRn@, and @mkHsOpTyRn@ in RnTypes), which expects that the input will be completely right-biased for types and left-biased for everything else. So we left-bias the -trees of @UInfixP@ and @UInfixE@ and use HsAppsTy for UInfixT. +trees of @UInfixP@ and @UInfixE@ and right-bias the trees of @UInfixT@. Sample input: @@ -1332,10 +1332,8 @@ cvtTypeKind ty_str ty } UInfixT t1 s t2 - -> do { t1' <- cvtType t1 - ; t2' <- cvtType t2 - ; s' <- tconName s - ; return $ cvtOpAppT t1' s' t2' + -> do { t2' <- cvtType t2 + ; cvtOpAppT t1 s t2' } -- Note [Converting UInfix] ParensT t @@ -1445,23 +1443,20 @@ cvtTyLit :: TH.TyLit -> HsTyLit cvtTyLit (TH.NumTyLit i) = HsNumTy NoSourceText i cvtTyLit (TH.StrTyLit s) = HsStrTy NoSourceText (fsLit s) -{- | @cvtOpAppT x op y@ takes converted arguments and flattens any HsAppsTy - structure in them. +{- | @cvtOpAppT x op y@ converts @op@ and @y@ and produces the operator +application @x `op` y@. The produced tree of infix types will be right-biased, +provided @y@ is. + +See the @cvtOpApp@ documentation for how this function works. -} -cvtOpAppT :: LHsType GhcPs -> RdrName -> LHsType GhcPs -> LHsType GhcPs -cvtOpAppT t1@(L loc1 _) op t2@(L loc2 _) - = L (combineSrcSpans loc1 loc2) $ - HsAppsTy noExt (t1' ++ [noLoc $ HsAppInfix noExt (noLoc op)] ++ t2') - where - t1' | L _ (HsAppsTy _ t1s) <- t1 - = t1s - | otherwise - = [noLoc $ HsAppPrefix noExt t1] - - t2' | L _ (HsAppsTy _ t2s) <- t2 - = t2s - | otherwise - = [noLoc $ HsAppPrefix noExt t2] +cvtOpAppT :: TH.Type -> TH.Name -> LHsType GhcPs -> CvtM (LHsType GhcPs) +cvtOpAppT (UInfixT x op2 y) op1 z + = do { l <- cvtOpAppT y op1 z + ; cvtOpAppT x op2 l } +cvtOpAppT x op y + = do { op' <- tconNameL op + ; x' <- cvtType x + ; returnL (mkHsOpTy x' op' y) } cvtKind :: TH.Kind -> CvtM (LHsKind GhcPs) cvtKind = cvtTypeKind "kind" diff --git a/compiler/hsSyn/HsDecls.hs b/compiler/hsSyn/HsDecls.hs index 076c590f0b..c7a0ea0716 100644 --- a/compiler/hsSyn/HsDecls.hs +++ b/compiler/hsSyn/HsDecls.hs @@ -784,11 +784,10 @@ variables and its return type are annotated. - An open type family always has a CUSK -- unannotated type variables (and return type) default to *. - - Additionally, if -XTypeInType is on, then a data definition with a top-level - :: must explicitly bind all kind variables to the right of the ::. - See test dependent/should_compile/KindLevels, which requires this case. - (Naturally, any kind variable mentioned before the :: should not be bound - after it.) + - A data definition with a top-level :: must explicitly bind all kind variables +to the right of the ::. See test dependent/should_compile/KindLevels, which +requires this case. (Naturally, any kind variable mentioned before the :: should +not be bound after it.) -} diff --git a/compiler/hsSyn/HsExtension.hs b/compiler/hsSyn/HsExtension.hs index eb56d3b24e..7243a6514e 100644 --- a/compiler/hsSyn/HsExtension.hs +++ b/compiler/hsSyn/HsExtension.hs @@ -902,7 +902,6 @@ type ForallXHsWildCardBndrs(c :: * -> Constraint) (x :: *) (b :: *) = type family XForAllTy x type family XQualTy x type family XTyVar x -type family XAppsTy x type family XAppTy x type family XFunTy x type family XListTy x @@ -912,6 +911,7 @@ type family XOpTy x type family XParTy x type family XIParamTy x type family XEqTy x +type family XStarTy x type family XKindSig x type family XSpliceTy x type family XDocTy x @@ -929,7 +929,6 @@ type ForallXType (c :: * -> Constraint) (x :: *) = ( c (XForAllTy x) , c (XQualTy x) , c (XTyVar x) - , c (XAppsTy x) , c (XAppTy x) , c (XFunTy x) , c (XListTy x) @@ -939,6 +938,7 @@ type ForallXType (c :: * -> Constraint) (x :: *) = , c (XParTy x) , c (XIParamTy x) , c (XEqTy x) + , c (XStarTy x) , c (XKindSig x) , c (XSpliceTy x) , c (XDocTy x) @@ -965,18 +965,6 @@ type ForallXTyVarBndr (c :: * -> Constraint) (x :: *) = -- --------------------------------------------------------------------- -type family XAppInfix x -type family XAppPrefix x -type family XXAppType x - -type ForallXAppType (c :: * -> Constraint) (x :: *) = - ( c (XAppInfix x) - , c (XAppPrefix x) - , c (XXAppType x) - ) - --- --------------------------------------------------------------------- - type family XConDeclField x type family XXConDeclField x diff --git a/compiler/hsSyn/HsInstances.hs b/compiler/hsSyn/HsInstances.hs index 70336d87e5..9a9f21d046 100644 --- a/compiler/hsSyn/HsInstances.hs +++ b/compiler/hsSyn/HsInstances.hs @@ -382,11 +382,6 @@ deriving instance Data (HsType GhcPs) deriving instance Data (HsType GhcRn) deriving instance Data (HsType GhcTc) --- deriving instance (DataIdLR p p) => Data (HsAppType p) -deriving instance Data (HsAppType GhcPs) -deriving instance Data (HsAppType GhcRn) -deriving instance Data (HsAppType GhcTc) - -- deriving instance (DataIdLR p p) => Data (ConDeclField p) deriving instance Data (ConDeclField GhcPs) deriving instance Data (ConDeclField GhcRn) diff --git a/compiler/hsSyn/HsTypes.hs b/compiler/hsSyn/HsTypes.hs index 11d301d816..8e959f7586 100644 --- a/compiler/hsSyn/HsTypes.hs +++ b/compiler/hsSyn/HsTypes.hs @@ -28,7 +28,6 @@ module HsTypes ( HsContext, LHsContext, HsTyLit(..), HsIPName(..), hsIPNameFS, - HsAppType(..),LHsAppType, LBangType, BangType, HsSrcBang(..), HsImplBang(..), @@ -57,9 +56,9 @@ module HsTypes ( splitLHsInstDeclTy, getLHsInstDeclHead, getLHsInstDeclClass_maybe, splitLHsPatSynTy, splitLHsForAllTy, splitLHsQualTy, splitLHsSigmaTy, - splitHsFunType, splitHsAppsTy, - splitHsAppTys, getAppsTyHead_maybe, hsTyGetAppHead_maybe, - mkHsOpTy, mkHsAppTy, mkHsAppTys, mkHsAppsTy, + splitHsFunType, + splitHsAppTys, hsTyGetAppHead_maybe, + mkHsOpTy, mkHsAppTy, mkHsAppTys, ignoreParens, hsSigType, hsSigWcType, hsLTyVarBndrToType, hsLTyVarBndrsToTypes, @@ -487,11 +486,6 @@ data HsType pass -- For details on above see note [Api annotations] in ApiAnnotation - | HsAppsTy (XAppsTy pass) - [LHsAppType pass] -- Used only before renaming, - -- Note [HsAppsTy] - -- ^ - 'ApiAnnotation.AnnKeywordId' : None - | HsAppTy (XAppTy pass) (LHsType pass) (LHsType pass) @@ -566,6 +560,11 @@ data HsType pass -- For details on above see note [Api annotations] in ApiAnnotation + | HsStarTy (XStarTy pass) + Bool -- Is this the Unicode variant? + -- Note [HsStarTy] + -- ^ - 'ApiAnnotation.AnnKeywordId' : None + | HsKindSig (XKindSig pass) (LHsType pass) -- (ty :: kind) (LHsKind pass) -- A type with a kind signature @@ -658,7 +657,6 @@ instance Outputable NewHsTypeX where type instance XForAllTy (GhcPass _) = NoExt type instance XQualTy (GhcPass _) = NoExt type instance XTyVar (GhcPass _) = NoExt -type instance XAppsTy (GhcPass _) = NoExt type instance XAppTy (GhcPass _) = NoExt type instance XFunTy (GhcPass _) = NoExt type instance XListTy (GhcPass _) = NoExt @@ -668,6 +666,7 @@ type instance XOpTy (GhcPass _) = NoExt type instance XParTy (GhcPass _) = NoExt type instance XIParamTy (GhcPass _) = NoExt type instance XEqTy (GhcPass _) = NoExt +type instance XStarTy (GhcPass _) = NoExt type instance XKindSig (GhcPass _) = NoExt type instance XSpliceTy GhcPs = NoExt @@ -709,27 +708,6 @@ newtype HsWildCardInfo -- See Note [The wildcard story for types] -- A anonymous wild card ('_'). A fresh Name is generated for -- each individual anonymous wildcard during renaming --- | Located Haskell Application Type -type LHsAppType pass = Located (HsAppType pass) - -- ^ 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSimpleQuote' - --- | Haskell Application Type -data HsAppType pass - = HsAppInfix (XAppInfix pass) - (Located (IdP pass)) -- either a symbol or an id in backticks - | HsAppPrefix (XAppPrefix pass) - (LHsType pass) -- anything else, including things like (+) - | XAppType - (XXAppType pass) - -type instance XAppInfix (GhcPass _) = NoExt -type instance XAppPrefix (GhcPass _) = NoExt -type instance XXAppType (GhcPass _) = NoExt - -instance (p ~ GhcPass pass, OutputableBndrId p) - => Outputable (HsAppType p) where - ppr = ppr_app_ty - {- Note [HsForAllTy tyvar binders] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -785,16 +763,18 @@ HsTyVar: A name in a type or kind. The 'Promoted' field in an HsTyVar captures whether the type was promoted in the source code by prefixing an apostrophe. -Note [HsAppsTy] +Note [HsStarTy] ~~~~~~~~~~~~~~~ -How to parse +When the StarIsType extension is enabled, we want to treat '*' and its Unicode +variant identically to 'Data.Kind.Type'. Unfortunately, doing so in the parser +would mean that when we pretty-print it back, we don't know whether the user +wrote '*' or 'Type', and lose the parse/ppr roundtrip property. - Foo * Int +As a workaround, we parse '*' as HsStarTy (if it stands for 'Data.Kind.Type') +and then desugar it to 'Data.Kind.Type' in the typechecker (see tc_hs_type). +When '*' is a regular type operator (StarIsType is disabled), HsStarTy is not +involved. -? Is it `(*) Foo Int` or `Foo GHC.Types.* Int`? There's no way to know until renaming. -So we just take type expressions like this and put each component in a list, so be -sorted out in the renamer. The sorting out is done by RnTypes.mkHsOpTyRn. This means -that the parser should never produce HsAppTy or HsOpTy. Note [Promoted lists and tuples] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1042,12 +1022,6 @@ mkHsAppTys :: LHsType (GhcPass p) -> [LHsType (GhcPass p)] -> LHsType (GhcPass p) mkHsAppTys = foldl mkHsAppTy -mkHsAppsTy :: [LHsAppType GhcPs] -> HsType GhcPs --- In the common case of a singleton non-operator, --- avoid the clutter of wrapping in a HsAppsTy -mkHsAppsTy [L _ (HsAppPrefix _ (L _ ty))] = ty -mkHsAppsTy app_tys = HsAppsTy NoExt app_tys - {- ************************************************************************ * * @@ -1083,38 +1057,7 @@ splitHsFunType orig_ty@(L _ (HsAppTy _ t1 t2)) splitHsFunType other = ([], other) --------------------------------- --- | Retrieves the head of an HsAppsTy, if this can be done unambiguously, --- without consulting fixities. -getAppsTyHead_maybe :: [LHsAppType (GhcPass p)] - -> Maybe ( LHsType (GhcPass p) - , [LHsType (GhcPass p)], LexicalFixity) -getAppsTyHead_maybe tys = case splitHsAppsTy tys of - ([app1:apps], []) -> -- no symbols, some normal types - Just (mkHsAppTys app1 apps, [], Prefix) - ([app1l:appsl, app1r:appsr], [L loc op]) -> -- one operator - Just ( L loc (HsTyVar noExt NotPromoted (L loc op)) - , [mkHsAppTys app1l appsl, mkHsAppTys app1r appsr], Infix) - _ -> -- can't figure it out - Nothing - --- | Splits a [HsAppType pass] (the payload of an HsAppsTy) into regions of --- prefix types (normal types) and infix operators. --- If @splitHsAppsTy tys = (non_syms, syms)@, then @tys@ starts with the first --- element of @non_syms@ followed by the first element of @syms@ followed by --- the next element of @non_syms@, etc. It is guaranteed that the non_syms list --- has one more element than the syms list. -splitHsAppsTy :: [LHsAppType pass] -> ([[LHsType pass]], [Located (IdP pass)]) -splitHsAppsTy = go [] [] [] - where - go acc acc_non acc_sym [] = (reverse (reverse acc : acc_non), reverse acc_sym) - go acc acc_non acc_sym (L _ (HsAppPrefix _ ty) : rest) - = go (ty : acc) acc_non acc_sym rest - go acc acc_non acc_sym (L _ (HsAppInfix _ op) : rest) - = go [] (reverse acc : acc_non) (op : acc_sym) rest - go _ _ _ (L _ (XAppType _):_) = panic "splitHsAppsTy" - --- Retrieve the name of the "head" of a nested type application +-- retrieve the name of the "head" of a nested type application -- somewhat like splitHsAppTys, but a little more thorough -- used to examine the result of a GADT-like datacon, so it doesn't handle -- *all* cases (like lists, tuples, (~), etc.) @@ -1123,9 +1066,6 @@ hsTyGetAppHead_maybe :: LHsType (GhcPass p) hsTyGetAppHead_maybe = go [] where go tys (L _ (HsTyVar _ _ ln)) = Just (ln, tys) - go tys (L _ (HsAppsTy _ apps)) - | Just (head, args, _) <- getAppsTyHead_maybe apps - = go (args ++ tys) head go tys (L _ (HsAppTy _ l r)) = go (r : tys) l go tys (L _ (HsOpTy _ l (L loc n) r)) = Just (L loc n, l : r : tys) go tys (L _ (HsParTy _ t)) = go tys t @@ -1134,7 +1074,6 @@ hsTyGetAppHead_maybe = go [] splitHsAppTys :: LHsType GhcRn -> [LHsType GhcRn] -> (LHsType GhcRn, [LHsType GhcRn]) - -- no need to worry about HsAppsTy here splitHsAppTys (L _ (HsAppTy _ f a)) as = splitHsAppTys f (a:as) splitHsAppTys (L _ (HsParTy _ f)) as = splitHsAppTys f as splitHsAppTys f as = (f,as) @@ -1459,8 +1398,7 @@ ppr_mono_ty (HsWildCardTy {}) = char '_' ppr_mono_ty (HsEqTy _ ty1 ty2) = ppr_mono_lty ty1 <+> char '~' <+> ppr_mono_lty ty2 -ppr_mono_ty (HsAppsTy _ tys) - = hsep (map (ppr_app_ty . unLoc) tys) +ppr_mono_ty (HsStarTy _ isUni) = char (if isUni then '★' else '*') ppr_mono_ty (HsAppTy _ fun_ty arg_ty) = hsep [ppr_mono_lty fun_ty, ppr_mono_lty arg_ty] @@ -1493,19 +1431,6 @@ ppr_fun_ty ty1 ty2 sep [p1, text "->" <+> p2] -------------------------- -ppr_app_ty :: (OutputableBndrId (GhcPass p)) => HsAppType (GhcPass p) -> SDoc -ppr_app_ty (HsAppInfix _ (L _ n)) = pprInfixOcc n -ppr_app_ty (HsAppPrefix _ (L _ (HsTyVar _ NotPromoted (L _ n)))) - = pprPrefixOcc n -ppr_app_ty (HsAppPrefix _ (L _ (HsTyVar _ Promoted (L _ n)))) - = space <> quote (pprPrefixOcc n) -- We need a space before the ' above, so - -- the parser does not attach it to the - -- previous symbol -ppr_app_ty (HsAppPrefix _ ty) = ppr_mono_lty ty - -ppr_app_ty (XAppType ty) = ppr ty - --------------------------- ppr_tylit :: HsTyLit -> SDoc ppr_tylit (HsNumTy _ i) = integer i ppr_tylit (HsStrTy _ s) = text (show s) @@ -1533,7 +1458,7 @@ hsTypeNeedsParens p = go go (HsTyLit{}) = False go (HsWildCardTy{}) = False go (HsEqTy{}) = p >= opPrec - go (HsAppsTy _ args) = p >= appPrec && not (null args) + go (HsStarTy{}) = False go (HsAppTy{}) = p >= appPrec go (HsOpTy{}) = p >= opPrec go (HsParTy{}) = False diff --git a/compiler/iface/IfaceType.hs b/compiler/iface/IfaceType.hs index 9426a30d95..537f419cc4 100644 --- a/compiler/iface/IfaceType.hs +++ b/compiler/iface/IfaceType.hs @@ -1020,7 +1020,7 @@ pprTyTcApp' ctxt_prec tc tys dflags style | tc `ifaceTyConHasKey` tYPETyConKey , ITC_Vis (IfaceTyConApp rep ITC_Nil) ITC_Nil <- tys , rep `ifaceTyConHasKey` liftedRepDataConKey - = kindStar + = kindType | otherwise = getPprDebug $ \dbg -> @@ -1130,10 +1130,8 @@ ppr_iface_tc_app pp _ tc [ty] | tc `ifaceTyConHasKey` listTyConKey = pprPromotionQuote tc <> brackets (pp topPrec ty) ppr_iface_tc_app pp ctxt_prec tc tys - | tc `ifaceTyConHasKey` starKindTyConKey - || tc `ifaceTyConHasKey` liftedTypeKindTyConKey - || tc `ifaceTyConHasKey` unicodeStarKindTyConKey - = kindStar -- Handle unicode; do not wrap * in parens + | tc `ifaceTyConHasKey` liftedTypeKindTyConKey + = kindType | not (isSymOcc (nameOccName (ifaceTyConName tc))) = pprIfacePrefixApp ctxt_prec (ppr tc) (map (pp appPrec) tys) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 09481591ce..13570dbfee 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -36,6 +36,7 @@ module DynFlags ( xopt, xopt_set, xopt_unset, lang_set, useUnicodeSyntax, + useStarIsType, whenGeneratingDynamicToo, ifGeneratingDynamicToo, whenCannotGenerateDynamicToo, dynamicTooMkDynamicDynFlags, @@ -804,6 +805,7 @@ data WarningFlag = | Opt_WarnPartialFields -- Since 8.4 | Opt_WarnMissingExportList | Opt_WarnInaccessibleCode + | Opt_WarnStarIsType -- Since 8.6 deriving (Eq, Show, Enum) data Language = Haskell98 | Haskell2010 @@ -2102,6 +2104,8 @@ languageExtensions Nothing languageExtensions (Just Haskell98) = [LangExt.ImplicitPrelude, + -- See Note [When is StarIsType enabled] + LangExt.StarIsType, LangExt.MonomorphismRestriction, LangExt.NPlusKPatterns, LangExt.DatatypeContexts, @@ -2116,6 +2120,8 @@ languageExtensions (Just Haskell98) languageExtensions (Just Haskell2010) = [LangExt.ImplicitPrelude, + -- See Note [When is StarIsType enabled] + LangExt.StarIsType, LangExt.MonomorphismRestriction, LangExt.DatatypeContexts, LangExt.TraditionalRecordSyntax, @@ -2250,6 +2256,9 @@ lang_set dflags lang = useUnicodeSyntax :: DynFlags -> Bool useUnicodeSyntax = gopt Opt_PrintUnicodeSyntax +useStarIsType :: DynFlags -> Bool +useStarIsType = xopt LangExt.StarIsType + -- | Set the Haskell language standard to use setLanguage :: Language -> DynP () setLanguage l = upd (`lang_set` Just l) @@ -3835,6 +3844,7 @@ wWarningFlagsDeps = [ flagSpec "simplifiable-class-constraints" Opt_WarnSimplifiableClassConstraints, flagSpec "missing-home-modules" Opt_WarnMissingHomeModules, flagSpec "unrecognised-warning-flags" Opt_WarnUnrecognisedWarningFlags, + flagSpec "star-is-type" Opt_WarnStarIsType, flagSpec "partial-fields" Opt_WarnPartialFields ] -- | These @-\<blah\>@ flags can all be reversed with @-no-\<blah\>@ @@ -4204,6 +4214,7 @@ xFlagsDeps = [ flagSpec "RoleAnnotations" LangExt.RoleAnnotations, flagSpec "ScopedTypeVariables" LangExt.ScopedTypeVariables, flagSpec "StandaloneDeriving" LangExt.StandaloneDeriving, + flagSpec "StarIsType" LangExt.StarIsType, flagSpec "StaticPointers" LangExt.StaticPointers, flagSpec "Strict" LangExt.Strict, flagSpec "StrictData" LangExt.StrictData, @@ -4330,9 +4341,12 @@ impliedXFlags , (LangExt.TypeFamilies, turnOn, LangExt.KindSignatures) -- Type families use kind signatures , (LangExt.PolyKinds, turnOn, LangExt.KindSignatures) -- Ditto polymorphic kinds + + -- TypeInType is now just a synonym for a couple of other extensions. , (LangExt.TypeInType, turnOn, LangExt.DataKinds) , (LangExt.TypeInType, turnOn, LangExt.PolyKinds) , (LangExt.TypeInType, turnOn, LangExt.KindSignatures) + , (LangExt.TypeInType, turnOff, LangExt.StarIsType) -- AutoDeriveTypeable is not very useful without DeriveDataTypeable , (LangExt.AutoDeriveTypeable, turnOn, LangExt.DeriveDataTypeable) @@ -4344,6 +4358,9 @@ impliedXFlags , (LangExt.ImpredicativeTypes, turnOn, LangExt.RankNTypes) + -- See Note [When is StarIsType enabled] + , (LangExt.TypeOperators, turnOff, LangExt.StarIsType) + -- Record wild-cards implies field disambiguation -- Otherwise if you write (C {..}) you may well get -- stuff like " 'a' not in scope ", which is a bit silly @@ -4364,6 +4381,20 @@ impliedXFlags , (LangExt.Strict, turnOn, LangExt.StrictData) ] +-- Note [When is StarIsType enabled] +-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-- The StarIsType extension determines whether to treat '*' as a regular type +-- operator or as a synonym for 'Data.Kind.Type'. Many existing pre-TypeInType +-- programs expect '*' to be synonymous with 'Type', so by default StarIsType is +-- enabled. +-- +-- However, programs that use TypeOperators might expect to repurpose '*' for +-- multiplication or another binary operation, so we make TypeOperators imply +-- NoStarIsType. +-- +-- It is still possible to have TypeOperators and StarIsType enabled at the same +-- time, although it's not recommended. + -- Note [Documenting optimisation flags] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- diff --git a/compiler/main/DynFlags.hs-boot b/compiler/main/DynFlags.hs-boot index 7440e5db00..823fd22854 100644 --- a/compiler/main/DynFlags.hs-boot +++ b/compiler/main/DynFlags.hs-boot @@ -13,6 +13,7 @@ pprCols :: DynFlags -> Int unsafeGlobalDynFlags :: DynFlags useUnicode :: DynFlags -> Bool useUnicodeSyntax :: DynFlags -> Bool +useStarIsType :: DynFlags -> Bool shouldUseColor :: DynFlags -> Bool shouldUseHexWordLiterals :: DynFlags -> Bool hasPprDebug :: DynFlags -> Bool diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs index 9823c60f70..8949799198 100644 --- a/compiler/main/HscTypes.hs +++ b/compiler/main/HscTypes.hs @@ -1834,8 +1834,7 @@ mkPrintUnqualified dflags env = QueryQualify qual_name forceUnqualNames :: [Name] forceUnqualNames = - map tyConName [ constraintKindTyCon, heqTyCon, coercibleTyCon - , starKindTyCon, unicodeStarKindTyCon ] + map tyConName [ constraintKindTyCon, heqTyCon, coercibleTyCon ] ++ [ eqTyConName ] right_name gre = nameModule_maybe (gre_name gre) == Just mod diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 69dc0992c8..2887edff04 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -68,6 +68,8 @@ module Lexer ( explicitNamespacesEnabled, patternSynonymsEnabled, sccProfilingOn, hpcEnabled, + typeOperatorsEnabled, + starIsTypeEnabled, addWarning, lexTokenStream, addAnnotation,AddAnn,addAnnsAt,mkParensApiAnn, @@ -682,6 +684,7 @@ data Token | ITdarrow IsUnicodeSyntax | ITminus | ITbang + | ITstar IsUnicodeSyntax | ITdot | ITbiglam -- GHC-extension symbols @@ -893,6 +896,8 @@ reservedSymsFM = listToUFM $ ,("-", ITminus, always) ,("!", ITbang, always) + ,("*", ITstar NormalSyntax, starIsTypeEnabled) + -- For 'forall a . t' ,(".", ITdot, always) -- \i -> explicitForallEnabled i || inRulePrag i) @@ -915,6 +920,8 @@ reservedSymsFM = listToUFM $ \i -> unicodeSyntaxEnabled i && arrowsEnabled i) ,("⤜", ITRarrowtail UnicodeSyntax, \i -> unicodeSyntaxEnabled i && arrowsEnabled i) + ,("★", ITstar UnicodeSyntax, + \i -> unicodeSyntaxEnabled i && starIsTypeEnabled i) -- ToDo: ideally, → and ∷ should be "specials", so that they cannot -- form part of a large operator. This would let us have a better @@ -2257,6 +2264,8 @@ data ExtBits | TypeApplicationsBit | StaticPointersBit | NumericUnderscoresBit + | TypeOperatorsBit + | StarIsTypeBit deriving Enum @@ -2325,6 +2334,10 @@ staticPointersEnabled :: ExtsBitmap -> Bool staticPointersEnabled = xtest StaticPointersBit numericUnderscoresEnabled :: ExtsBitmap -> Bool numericUnderscoresEnabled = xtest NumericUnderscoresBit +typeOperatorsEnabled :: ExtsBitmap -> Bool +typeOperatorsEnabled = xtest TypeOperatorsBit +starIsTypeEnabled :: ExtsBitmap -> Bool +starIsTypeEnabled = xtest StarIsTypeBit -- PState for parsing options pragmas -- @@ -2343,47 +2356,56 @@ mkParserFlags flags = , pExtsBitmap = bitmap } where - bitmap = FfiBit `setBitIf` xopt LangExt.ForeignFunctionInterface flags - .|. InterruptibleFfiBit `setBitIf` xopt LangExt.InterruptibleFFI flags - .|. CApiFfiBit `setBitIf` xopt LangExt.CApiFFI flags - .|. ArrowsBit `setBitIf` xopt LangExt.Arrows flags - .|. ThBit `setBitIf` xopt LangExt.TemplateHaskell flags - .|. ThQuotesBit `setBitIf` xopt LangExt.TemplateHaskellQuotes flags - .|. QqBit `setBitIf` xopt LangExt.QuasiQuotes flags - .|. IpBit `setBitIf` xopt LangExt.ImplicitParams flags - .|. OverloadedLabelsBit `setBitIf` xopt LangExt.OverloadedLabels flags - .|. ExplicitForallBit `setBitIf` xopt LangExt.ExplicitForAll flags - .|. BangPatBit `setBitIf` xopt LangExt.BangPatterns flags - .|. HaddockBit `setBitIf` gopt Opt_Haddock flags - .|. MagicHashBit `setBitIf` xopt LangExt.MagicHash flags - .|. RecursiveDoBit `setBitIf` xopt LangExt.RecursiveDo flags - .|. UnicodeSyntaxBit `setBitIf` xopt LangExt.UnicodeSyntax flags - .|. UnboxedTuplesBit `setBitIf` xopt LangExt.UnboxedTuples flags - .|. UnboxedSumsBit `setBitIf` xopt LangExt.UnboxedSums flags - .|. DatatypeContextsBit `setBitIf` xopt LangExt.DatatypeContexts flags - .|. TransformComprehensionsBit `setBitIf` xopt LangExt.TransformListComp flags - .|. TransformComprehensionsBit `setBitIf` xopt LangExt.MonadComprehensions flags - .|. RawTokenStreamBit `setBitIf` gopt Opt_KeepRawTokenStream flags - .|. HpcBit `setBitIf` gopt Opt_Hpc flags - .|. AlternativeLayoutRuleBit `setBitIf` xopt LangExt.AlternativeLayoutRule flags - .|. RelaxedLayoutBit `setBitIf` xopt LangExt.RelaxedLayout flags - .|. SccProfilingOnBit `setBitIf` gopt Opt_SccProfilingOn flags - .|. NondecreasingIndentationBit `setBitIf` xopt LangExt.NondecreasingIndentation flags - .|. SafeHaskellBit `setBitIf` safeImportsOn flags - .|. TraditionalRecordSyntaxBit `setBitIf` xopt LangExt.TraditionalRecordSyntax flags - .|. ExplicitNamespacesBit `setBitIf` xopt LangExt.ExplicitNamespaces flags - .|. LambdaCaseBit `setBitIf` xopt LangExt.LambdaCase flags - .|. BinaryLiteralsBit `setBitIf` xopt LangExt.BinaryLiterals flags - .|. NegativeLiteralsBit `setBitIf` xopt LangExt.NegativeLiterals flags - .|. HexFloatLiteralsBit `setBitIf` xopt LangExt.HexFloatLiterals flags - .|. PatternSynonymsBit `setBitIf` xopt LangExt.PatternSynonyms flags - .|. TypeApplicationsBit `setBitIf` xopt LangExt.TypeApplications flags - .|. StaticPointersBit `setBitIf` xopt LangExt.StaticPointers flags - .|. NumericUnderscoresBit `setBitIf` xopt LangExt.NumericUnderscores flags - - setBitIf :: ExtBits -> Bool -> ExtsBitmap - b `setBitIf` cond | cond = xbit b - | otherwise = 0 + bitmap = safeHaskellBit .|. langExtBits .|. optBits + safeHaskellBit = + SafeHaskellBit `setBitIf` safeImportsOn flags + langExtBits = + FfiBit `xoptBit` LangExt.ForeignFunctionInterface + .|. InterruptibleFfiBit `xoptBit` LangExt.InterruptibleFFI + .|. CApiFfiBit `xoptBit` LangExt.CApiFFI + .|. ArrowsBit `xoptBit` LangExt.Arrows + .|. ThBit `xoptBit` LangExt.TemplateHaskell + .|. ThQuotesBit `xoptBit` LangExt.TemplateHaskellQuotes + .|. QqBit `xoptBit` LangExt.QuasiQuotes + .|. IpBit `xoptBit` LangExt.ImplicitParams + .|. OverloadedLabelsBit `xoptBit` LangExt.OverloadedLabels + .|. ExplicitForallBit `xoptBit` LangExt.ExplicitForAll + .|. BangPatBit `xoptBit` LangExt.BangPatterns + .|. MagicHashBit `xoptBit` LangExt.MagicHash + .|. RecursiveDoBit `xoptBit` LangExt.RecursiveDo + .|. UnicodeSyntaxBit `xoptBit` LangExt.UnicodeSyntax + .|. UnboxedTuplesBit `xoptBit` LangExt.UnboxedTuples + .|. UnboxedSumsBit `xoptBit` LangExt.UnboxedSums + .|. DatatypeContextsBit `xoptBit` LangExt.DatatypeContexts + .|. TransformComprehensionsBit `xoptBit` LangExt.TransformListComp + .|. TransformComprehensionsBit `xoptBit` LangExt.MonadComprehensions + .|. AlternativeLayoutRuleBit `xoptBit` LangExt.AlternativeLayoutRule + .|. RelaxedLayoutBit `xoptBit` LangExt.RelaxedLayout + .|. NondecreasingIndentationBit `xoptBit` LangExt.NondecreasingIndentation + .|. TraditionalRecordSyntaxBit `xoptBit` LangExt.TraditionalRecordSyntax + .|. ExplicitNamespacesBit `xoptBit` LangExt.ExplicitNamespaces + .|. LambdaCaseBit `xoptBit` LangExt.LambdaCase + .|. BinaryLiteralsBit `xoptBit` LangExt.BinaryLiterals + .|. NegativeLiteralsBit `xoptBit` LangExt.NegativeLiterals + .|. HexFloatLiteralsBit `xoptBit` LangExt.HexFloatLiterals + .|. PatternSynonymsBit `xoptBit` LangExt.PatternSynonyms + .|. TypeApplicationsBit `xoptBit` LangExt.TypeApplications + .|. StaticPointersBit `xoptBit` LangExt.StaticPointers + .|. NumericUnderscoresBit `xoptBit` LangExt.NumericUnderscores + .|. TypeOperatorsBit `xoptBit` LangExt.TypeOperators + .|. StarIsTypeBit `xoptBit` LangExt.StarIsType + optBits = + HaddockBit `goptBit` Opt_Haddock + .|. RawTokenStreamBit `goptBit` Opt_KeepRawTokenStream + .|. HpcBit `goptBit` Opt_Hpc + .|. SccProfilingOnBit `goptBit` Opt_SccProfilingOn + + xoptBit bit ext = bit `setBitIf` xopt ext flags + goptBit bit opt = bit `setBitIf` gopt opt flags + + setBitIf :: ExtBits -> Bool -> ExtsBitmap + b `setBitIf` cond | cond = xbit b + | otherwise = 0 -- | Creates a parse state from a 'DynFlags' value mkPState :: DynFlags -> StringBuffer -> RealSrcLoc -> PState diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 25edb3e591..c1ee8a4855 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -88,7 +88,7 @@ import GhcPrelude import qualified GHC.LanguageExtensions as LangExt } -%expect 233 -- shift/reduce conflicts +%expect 235 -- shift/reduce conflicts {- Last updated: 04 June 2018 @@ -158,7 +158,7 @@ Shift parses as (per longest-parse rule): ------------------------------------------------------------------------------- -state 143 contains 14 shift/reduce conflicts. +state 144 contains 15 shift/reduce conflicts. exp -> infixexp . '::' sigtype exp -> infixexp . '-<' exp @@ -169,7 +169,7 @@ state 143 contains 14 shift/reduce conflicts. infixexp -> infixexp . qop exp10 Conflicts: ':' '::' '-' '!' '-<' '>-' '-<<' '>>-' - '.' '`' VARSYM CONSYM QVARSYM QCONSYM + '.' '`' '*' VARSYM CONSYM QVARSYM QCONSYM Examples of ambiguity: 'if x then y else z -< e' @@ -183,7 +183,7 @@ Shift parses as (per longest-parse rule): ------------------------------------------------------------------------------- -state 148 contains 68 shift/reduce conflicts. +state 149 contains 67 shift/reduce conflicts. *** exp10 -> fexp . fexp -> fexp . aexp @@ -201,7 +201,7 @@ Shift parses as (per longest-parse rule): ------------------------------------------------------------------------------- -state 204 contains 28 shift/reduce conflicts. +state 204 contains 27 shift/reduce conflicts. aexp2 -> TH_TY_QUOTE . tyvar aexp2 -> TH_TY_QUOTE . gtycon @@ -220,7 +220,7 @@ Shift parses as (per longest-parse rule): ------------------------------------------------------------------------------- -state 308 contains 1 shift/reduce conflicts. +state 300 contains 1 shift/reduce conflicts. rule -> STRING . rule_activation rule_forall infixexp '=' exp @@ -238,7 +238,7 @@ a rule instructing how to rewrite the expression '[0] f'. ------------------------------------------------------------------------------- -state 318 contains 1 shift/reduce conflict. +state 310 contains 1 shift/reduce conflict. *** type -> btype . type -> btype . '->' ctype @@ -249,7 +249,7 @@ Same as state 61 but without contexts. ------------------------------------------------------------------------------- -state 362 contains 1 shift/reduce conflicts. +state 354 contains 1 shift/reduce conflicts. tup_exprs -> commas . tup_tail sysdcon_nolist -> '(' commas . ')' @@ -264,7 +264,7 @@ if -XTupleSections is not specified. ------------------------------------------------------------------------------- -state 418 contains 1 shift/reduce conflicts. +state 409 contains 1 shift/reduce conflicts. tup_exprs -> commas . tup_tail sysdcon_nolist -> '(#' commas . '#)' @@ -272,21 +272,21 @@ state 418 contains 1 shift/reduce conflicts. Conflict: '#)' (empty tup_tail reduces) -Same as State 362 for unboxed tuples. +Same as State 354 for unboxed tuples. ------------------------------------------------------------------------------- -state 429 contains 68 shift/reduce conflicts. +state 417 contains 67 shift/reduce conflicts. *** exp10 -> '-' fexp . fexp -> fexp . aexp fexp -> fexp . TYPEAPP atype -Same as 148 but with a unary minus. +Same as 149 but with a unary minus. ------------------------------------------------------------------------------- -state 493 contains 1 shift/reduce conflict. +state 481 contains 1 shift/reduce conflict. oqtycon -> '(' qtyconsym . ')' *** qtyconop -> qtyconsym . @@ -300,7 +300,7 @@ parenthesized infix type expression of length 1. ------------------------------------------------------------------------------- -state 694 contains 1 shift/reduce conflicts. +state 675 contains 1 shift/reduce conflicts. *** aexp2 -> ipvar . dbind -> ipvar . '=' exp @@ -315,7 +315,7 @@ sensible meaning, namely the lhs of an implicit binding. ------------------------------------------------------------------------------- -state 771 contains 1 shift/reduce conflicts. +state 752 contains 1 shift/reduce conflicts. rule -> STRING rule_activation . rule_forall infixexp '=' exp @@ -332,7 +332,7 @@ doesn't include 'forall'. ------------------------------------------------------------------------------- -state 1019 contains 1 shift/reduce conflicts. +state 986 contains 1 shift/reduce conflicts. transformqual -> 'then' 'group' . 'using' exp transformqual -> 'then' 'group' . 'by' exp 'using' exp @@ -342,7 +342,7 @@ state 1019 contains 1 shift/reduce conflicts. ------------------------------------------------------------------------------- -state 1404 contains 1 shift/reduce conflict. +state 1367 contains 1 shift/reduce conflict. *** atype -> tyvar . tv_bndr -> '(' tyvar . '::' kind ')' @@ -526,6 +526,7 @@ are the most common patterns, rewritten as regular expressions for clarity: '=>' { L _ (ITdarrow _) } '-' { L _ ITminus } '!' { L _ ITbang } + '*' { L _ (ITstar _) } '-<' { L _ (ITlarrowtail _) } -- for arrow notation '>-' { L _ (ITrarrowtail _) } -- for arrow notation '-<<' { L _ (ITLarrowtail _) } -- for arrow notation @@ -1160,11 +1161,7 @@ deriv_strategy_no_via :: { LDerivStrategy GhcPs } [mj AnnNewtype $1] } deriv_strategy_via :: { LDerivStrategy GhcPs } - : 'via' tyapp {% splitTildeApps [$2] >>= \tys -> let - ty :: LHsType GhcPs - ty = sL1 $1 $ mkHsAppsTy tys - - in ams (sLL $1 $> (ViaStrategy (mkLHsSigType ty))) + : 'via' type {% ams (sLL $1 $> (ViaStrategy (mkLHsSigType $2))) [mj AnnVia $1] } deriv_standalone_strategy :: { Maybe (LDerivStrategy GhcPs) } @@ -1856,7 +1853,7 @@ context :: { LHsContext GhcPs } } } context_no_ops :: { LHsContext GhcPs } - : btype_no_ops {% do { ty <- splitTilde $1 + : btype_no_ops {% do { ty <- splitTilde (reverse (unLoc $1)) ; (anns,ctx) <- checkContext ty ; if null (unLoc ctx) then addAnnotation (gl ty) AnnUnit (gl ty) @@ -1911,29 +1908,27 @@ typedoc :: { LHsType GhcPs } -- See Note [Parsing ~] btype :: { LHsType GhcPs } - : tyapps {% splitTildeApps (reverse (unLoc $1)) >>= - \ts -> return $ sL1 $1 $ mkHsAppsTy ts } + : tyapps {% mergeOps (unLoc $1) } -- Used for parsing Haskell98-style data constructors, -- in order to forbid the blasphemous -- > data Foo = Int :+ Char :* Bool -- See also Note [Parsing data constructors is hard] in RdrHsSyn -btype_no_ops :: { LHsType GhcPs } - : btype_no_ops atype_docs { sLL $1 $> $ HsAppTy noExt $1 $2 } - | atype_docs { $1 } +btype_no_ops :: { Located [LHsType GhcPs] } -- NB: This list is reversed + : atype_docs { sL1 $1 [$1] } + | btype_no_ops atype_docs { sLL $1 $> $ $2 : (unLoc $1) } -tyapps :: { Located [LHsAppType GhcPs] } -- NB: This list is reversed +tyapps :: { Located [Located TyEl] } -- NB: This list is reversed : tyapp { sL1 $1 [$1] } | tyapps tyapp { sLL $1 $> $ $2 : (unLoc $1) } --- See Note [HsAppsTy] in HsTypes -tyapp :: { LHsAppType GhcPs } - : atype { sL1 $1 $ HsAppPrefix noExt $1 } - | qtyconop { sL1 $1 $ HsAppInfix noExt $1 } - | tyvarop { sL1 $1 $ HsAppInfix noExt $1 } - | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ HsAppInfix noExt $2) +tyapp :: { Located TyEl } + : atype { sL1 $1 $ TyElOpd (unLoc $1) } + | qtyconop { sL1 $1 $ TyElOpr (unLoc $1) } + | tyvarop { sL1 $1 $ TyElOpr (unLoc $1) } + | SIMPLEQUOTE qconop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) [mj AnnSimpleQuote $1] } - | SIMPLEQUOTE varop {% ams (sLL $1 $> $ HsAppInfix noExt $2) + | SIMPLEQUOTE varop {% ams (sLL $1 $> $ TyElOpr (unLoc $2)) [mj AnnSimpleQuote $1] } atype_docs :: { LHsType GhcPs } @@ -1943,6 +1938,8 @@ atype_docs :: { LHsType GhcPs } atype :: { LHsType GhcPs } : ntgtycon { sL1 $1 (HsTyVar noExt NotPromoted $1) } -- Not including unit tuples | tyvar { sL1 $1 (HsTyVar noExt NotPromoted $1) } -- (See Note [Unit tuples]) + | '*' {% do { warnStarIsType (getLoc $1) + ; return $ sL1 $1 (HsStarTy noExt (isUnicode $1)) } } | strict_mark atype {% ams (sLL $1 $> (HsBangTy noExt (snd $ unLoc $1) $2)) (fst $ unLoc $1) } -- Constructor sigs only | '{' fielddecls '}' {% amms (checkRecordSyntax @@ -2061,13 +2058,13 @@ Note [Parsing ~] Due to parsing conflicts between laziness annotations in data type declarations (see strict_mark) and equality types ~'s are always -parsed as laziness annotations, and turned into HsEqTy's in the +parsed as laziness annotations, and turned into HsOpTy's in the correct places using RdrHsSyn.splitTilde. Since strict_mark is parsed as part of atype which is part of type, typedoc and context (where HsEqTy previously appeared) it made most sense and was simplest to parse ~ as part of strict_mark and later -turn them into HsEqTy's. +turn them into HsOpTy's. -} @@ -2191,14 +2188,15 @@ forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr GhcPs]) } constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs, Maybe LHsDocString) } -- See Note [Parsing data constructors is hard] in RdrHsSyn - : btype_no_ops {% do { c <- splitCon $1 - ; return $ sLL $1 $> c } } + : btype_no_ops {% do { c <- splitCon (unLoc $1) + ; return $ sL1 $1 c } } | btype_no_ops conop maybe_docprev btype_no_ops - {% do { lhs <- splitTilde $1 - ; (_, ds_l) <- checkInfixConstr lhs - ; (rhs, ds_r) <- checkInfixConstr $4 + {% do { lhs <- splitTilde (reverse (unLoc $1)) + ; (_, ds_l) <- checkInfixConstr lhs + ; let rhs1 = foldl1 mkHsAppTy (reverse (unLoc $4)) + ; (rhs, ds_r) <- checkInfixConstr rhs1 ; return $ if isJust (ds_l `mplus` $3) - then sLL $1 $> ($2, InfixCon lhs $4, $3) + then sLL $1 $> ($2, InfixCon lhs rhs1, $3) else sLL $1 $> ($2, InfixCon lhs rhs, ds_r) } } fielddecls :: { [LConDeclField GhcPs] } @@ -3370,6 +3368,7 @@ special_id special_sym :: { Located FastString } special_sym : '!' {% ams (sL1 $1 (fsLit "!")) [mj AnnBang $1] } | '.' { sL1 $1 (fsLit ".") } + | '*' { sL1 $1 (fsLit (if isUnicode $1 then "★" else "*")) } ----------------------------------------------------------------------------- -- Data constructors @@ -3552,6 +3551,7 @@ isUnicode (L _ (IToparenbar iu)) = iu == UnicodeSyntax isUnicode (L _ (ITcparenbar iu)) = iu == UnicodeSyntax isUnicode (L _ (ITopenExpQuote _ iu)) = iu == UnicodeSyntax isUnicode (L _ (ITcloseQuote iu)) = iu == UnicodeSyntax +isUnicode (L _ (ITstar iu)) = iu == UnicodeSyntax isUnicode _ = False hasE :: Located Token -> Bool diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index 35371af9c8..64b74d3317 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -57,7 +57,8 @@ module RdrHsSyn ( checkRecordSyntax, checkEmptyGADTs, parseErrorSDoc, hintBangPat, - splitTilde, splitTildeApps, + splitTilde, + TyEl(..), mergeOps, -- Help with processing exports ImpExpSubSpec(..), @@ -67,6 +68,10 @@ module RdrHsSyn ( mkImpExpSubSpec, checkImportSpec, + -- Warnings and errors + warnStarIsType, + failOpFewArgs, + SumOrTuple (..), mkSumOrTuple ) where @@ -87,8 +92,7 @@ import Lexeme ( isLexCon ) import Type ( TyThing(..) ) import TysWiredIn ( cTupleTyConName, tupleTyCon, tupleDataCon, nilDataConName, nilDataConKey, - listTyConName, listTyConKey, - starKindTyConName, unicodeStarKindTyConName ) + listTyConName, listTyConKey ) import ForeignCall import PrelNames ( forall_tv_RDR, eqTyCon_RDR, allNameStrings ) import SrcLoc @@ -103,7 +107,7 @@ import ApiAnnotation import HsExtension ( noExt ) import Data.List import qualified GHC.LanguageExtensions as LangExt -import MonadUtils +import DynFlags ( WarningFlag(..) ) import Control.Monad import Text.ParserCombinators.ReadP as ReadP @@ -479,9 +483,15 @@ So the plan is: data T = (+++) will parse ok (since tycons can be operators), but we should reject it (Trac #12051). + +'splitCon' takes a reversed list @apps@ of types as input, such that +@foldl1 mkHsAppTy (reverse apps)@ yields the original type. This is because +this is easy for the parser to produce and we avoid the overhead of unrolling +'HsAppTy'. + -} -splitCon :: LHsType GhcPs +splitCon :: [LHsType GhcPs] -> P ( Located RdrName -- constructor name , HsConDeclDetails GhcPs -- constructor field information , Maybe LHsDocString -- docstring to go on the constructor @@ -491,15 +501,11 @@ splitCon :: LHsType GhcPs -- C Int Bool -- or C { x::Int, y::Bool } -- and returns the pieces -splitCon ty +splitCon apps = split apps' [] where - -- This is used somewhere where HsAppsTy is not used - unrollApps (L _ (HsAppTy _ t u)) = u : unrollApps t - unrollApps t = [t] - - apps = unrollApps ty oneDoc = [ () | L _ (HsDocTy{}) <- apps ] `lengthIs` 1 + ty = foldl1 mkHsAppTy (reverse apps) -- the trailing doc, if any, can be extracted first (apps', trailing_doc) @@ -865,15 +871,6 @@ checkTyClHdr is_cls ty | isRdrTc tc = return (ltc, t1:t2:acc, Infix, ann) go l (HsParTy _ ty) acc ann fix = goL ty acc (ann ++mkParensApiAnn l) fix go _ (HsAppTy _ t1 t2) acc ann fix = goL t1 (t2:acc) ann fix - go _ (HsAppsTy _ ts) acc ann _fix - | Just (head, args, fixity) <- getAppsTyHead_maybe ts - = goL head (args ++ acc) ann fixity - - go _ (HsAppsTy _ [L _ (HsAppInfix _ (L loc star))]) [] ann fix - | isStar star - = return (L loc (nameRdrName starKindTyConName), [], fix, ann) - | isUniStar star - = return (L loc (nameRdrName unicodeStarKindTyConName), [], fix, ann) go l (HsTupleTy _ HsBoxedOrConstraintTuple ts) [] ann fix = return (L l (nameRdrName tup_name), ts, fix, ann) @@ -927,10 +924,6 @@ checkContext (L l orig_t) -- be used as context constraints. = return (anns ++ mkParensApiAnn lp,L l ts) -- Ditto () - -- don't let HsAppsTy get in the way - check anns (L _ (HsAppsTy _ [L _ (HsAppPrefix _ ty)])) - = check anns ty - check anns (L lp1 (HsParTy _ ty)) -- to be sure HsParTy doesn't get into the way = check anns' ty @@ -1276,56 +1269,78 @@ isFunLhs e = go e [] [] _ -> return Nothing } go _ _ _ = return Nothing - --- | Transform btype_no_ops with strict_mark's into HsEqTy's --- (((~a) ~b) c) ~d ==> ((~a) ~ (b c)) ~ d -splitTilde :: LHsType GhcPs -> P (LHsType GhcPs) -splitTilde t = go t - where go (L loc (HsAppTy _ t1 t2)) - | L lo (HsBangTy _ (HsSrcBang NoSourceText NoSrcUnpack SrcLazy) t2') - <- t2 - = do - moveAnnotations lo loc - t1' <- go t1 - return (L loc (HsEqTy noExt t1' t2')) - | otherwise - = do - t1' <- go t1 - case t1' of - (L lo (HsEqTy _ tl tr)) -> do - let lr = combineLocs tr t2 - moveAnnotations lo loc - return (L loc (HsEqTy noExt tl - (L lr (HsAppTy noExt tr t2)))) - t -> do - return (L loc (HsAppTy noExt t t2)) - - go t = return t - - --- | Transform tyapps with strict_marks into uses of twiddle --- [~a, ~b, c, ~d] ==> (~a) ~ b c ~ d -splitTildeApps :: [LHsAppType GhcPs] -> P [LHsAppType GhcPs] -splitTildeApps [] = return [] -splitTildeApps (t : rest) = do - rest' <- concatMapM go rest - return (t : rest') - where go (L l (HsAppPrefix _ - (L loc (HsBangTy noExt - (HsSrcBang NoSourceText NoSrcUnpack SrcLazy) - ty)))) - = addAnnotation l AnnTilde tilde_loc >> - return - [L tilde_loc (HsAppInfix noExt (L tilde_loc eqTyCon_RDR)), - L l (HsAppPrefix noExt ty)] - -- NOTE: no annotation is attached to an HsAppPrefix, so the - -- surrounding SrcSpan is not critical - where - tilde_loc = srcSpanFirstCharacter loc - - go t = return [t] - - +-- | Transform a list of 'atype' with 'strict_mark' into +-- HsOpTy's of 'eqTyCon_RDR': +-- +-- [~a, ~b, c, ~d] ==> (~a) ~ ((b c) ~ d) +-- +-- See Note [Parsing ~] +splitTilde :: [LHsType GhcPs] -> P (LHsType GhcPs) +splitTilde [] = panic "splitTilde" +splitTilde (x:xs) = go x xs + where + -- We accumulate applications in the LHS until we encounter a laziness + -- annotation. For example, if we have [Foo, x, y, ~Bar, z], the 'lhs' + -- accumulator will become '(Foo x) y'. Then we strip the laziness + -- annotation off 'Bar' and process the tail [Bar, z] recursively. + -- + -- This leaves us with 'lhs = (Foo x) y' and 'rhs = Bar z'. + -- In case the tail contained more laziness annotations, they would be + -- processed similarly. This makes '~' right-associative. + go lhs [] = return lhs + go lhs (x:xs) + | L loc (HsBangTy _ (HsSrcBang NoSourceText NoSrcUnpack SrcLazy) t) <- x + = do { rhs <- splitTilde (t:xs) + ; let r = mkLHsOpTy lhs (tildeOp loc) rhs + ; moveAnnotations loc (getLoc r) + ; return r } + | otherwise + = go (mkHsAppTy lhs x) xs + + tildeOp loc = L (srcSpanFirstCharacter loc) eqTyCon_RDR + +-- | Either an operator or an operand. +data TyEl = TyElOpr RdrName | TyElOpd (HsType GhcPs) + +-- | Merge a /reversed/ and /non-empty/ soup of operators and operands +-- into a type. +-- +-- User input: @F x y + G a b * X@ +-- Input to 'mergeOps': [X, *, b, a, G, +, y, x, F] +-- Output corresponds to what the user wrote assuming all operators are of the +-- same fixity and right-associative. +-- +-- It's a bit silly that we're doing it at all, as the renamer will have to +-- rearrange this, and it'd be easier to keep things separate. +mergeOps :: [Located TyEl] -> P (LHsType GhcPs) +mergeOps = go [] id + where + -- clause (a): + -- when we encounter an operator, we must have accumulated + -- something for its rhs, and there must be something left + -- to build its lhs. + go acc ops_acc (L l (TyElOpr op):xs) = + if null acc || null xs + then failOpFewArgs (L l op) + else do { a <- splitTilde acc + ; go [] (\c -> mkLHsOpTy c (L l op) (ops_acc a)) xs } + + -- clause (b): + -- whenever an operand is encountered, it is added to the accumulator + go acc ops_acc (L l (TyElOpd a):xs) = go (L l a:acc) ops_acc xs + + -- clause (c): + -- at this point we know that 'acc' is non-empty because + -- there are three options when 'acc' can be empty: + -- 1. 'mergeOps' was called with an empty list, and this + -- should never happen + -- 2. 'mergeOps' was called with a list where the head is an + -- operator, this is handled by clause (a) + -- 3. 'mergeOps' was called with a list where the head is an + -- operand, this is handled by clause (b) + go acc ops_acc [] = + do { a <- splitTilde acc + ; return (ops_acc a) } --------------------------------------------------------------------------- -- Check for monad comprehensions @@ -1715,6 +1730,28 @@ isImpExpQcWildcard ImpExpQcWildcard = True isImpExpQcWildcard _ = False ----------------------------------------------------------------------------- +-- Warnings and failures + +warnStarIsType :: SrcSpan -> P () +warnStarIsType span = addWarning Opt_WarnStarIsType span msg + where + msg = text "Using" <+> quotes (text "*") + <+> text "(or its Unicode variant) to mean" + <+> quotes (text "Data.Kind.Type") + $$ text "relies on the StarIsType extension." + $$ text "Suggested fix: use" <+> quotes (text "Type") + <+> text "from" <+> quotes (text "Data.Kind") <+> text "instead." + +failOpFewArgs :: Located RdrName -> P a +failOpFewArgs (L loc op) = + do { type_operators <- extension typeOperatorsEnabled + ; star_is_type <- extension starIsTypeEnabled + ; let msg = too_few $$ starInfo (type_operators, star_is_type) op + ; parseErrorSDoc loc msg } + where + too_few = text "Operator applied to too few arguments:" <+> ppr op + +----------------------------------------------------------------------------- -- Misc utils parseErrorSDoc :: SrcSpan -> SDoc -> P a @@ -1748,3 +1785,8 @@ mkSumOrTuple Boxed l (Sum alt arity (L _ e)) = text "(" <+> ppr_bars (alt - 1) <+> ppr e <+> ppr_bars (arity - alt) <+> text ")" ppr_bars n = hsep (replicate n (Outputable.char '|')) + +mkLHsOpTy :: LHsType GhcPs -> Located RdrName -> LHsType GhcPs -> LHsType GhcPs +mkLHsOpTy x op y = + let loc = getLoc x `combineSrcSpans` getLoc op `combineSrcSpans` getLoc y + in L loc (mkHsOpTy x op y) diff --git a/compiler/prelude/PrelNames.hs b/compiler/prelude/PrelNames.hs index 88541120ca..5ed67d591f 100644 --- a/compiler/prelude/PrelNames.hs +++ b/compiler/prelude/PrelNames.hs @@ -1750,14 +1750,11 @@ eitherTyConKey = mkPreludeTyConUnique 84 -- Kind constructors liftedTypeKindTyConKey, tYPETyConKey, - constraintKindTyConKey, - starKindTyConKey, unicodeStarKindTyConKey, runtimeRepTyConKey, + constraintKindTyConKey, runtimeRepTyConKey, vecCountTyConKey, vecElemTyConKey :: Unique liftedTypeKindTyConKey = mkPreludeTyConUnique 87 tYPETyConKey = mkPreludeTyConUnique 88 constraintKindTyConKey = mkPreludeTyConUnique 92 -starKindTyConKey = mkPreludeTyConUnique 93 -unicodeStarKindTyConKey = mkPreludeTyConUnique 94 runtimeRepTyConKey = mkPreludeTyConUnique 95 vecCountTyConKey = mkPreludeTyConUnique 96 vecElemTyConKey = mkPreludeTyConUnique 97 @@ -2471,5 +2468,5 @@ The following names should be considered by GHCi to be in scope always. pretendNameIsInScope :: Name -> Bool pretendNameIsInScope n = any (n `hasKey`) - [ starKindTyConKey, liftedTypeKindTyConKey, tYPETyConKey + [ liftedTypeKindTyConKey, tYPETyConKey , runtimeRepTyConKey, liftedRepDataConKey ] diff --git a/compiler/prelude/PrelNames.hs-boot b/compiler/prelude/PrelNames.hs-boot index e25c83618f..0bd74d5577 100644 --- a/compiler/prelude/PrelNames.hs-boot +++ b/compiler/prelude/PrelNames.hs-boot @@ -4,5 +4,4 @@ import Module import Unique mAIN :: Module -starKindTyConKey :: Unique -unicodeStarKindTyConKey :: Unique +liftedTypeKindTyConKey :: Unique diff --git a/compiler/prelude/TysWiredIn.hs b/compiler/prelude/TysWiredIn.hs index 9ba2f1f45a..1156d810b9 100644 --- a/compiler/prelude/TysWiredIn.hs +++ b/compiler/prelude/TysWiredIn.hs @@ -91,9 +91,8 @@ module TysWiredIn ( -- * Kinds typeNatKindCon, typeNatKind, typeSymbolKindCon, typeSymbolKind, isLiftedTypeKindTyConName, liftedTypeKind, constraintKind, - starKindTyCon, starKindTyConName, - unicodeStarKindTyCon, unicodeStarKindTyConName, liftedTypeKindTyCon, constraintKindTyCon, + liftedTypeKindTyConName, -- * Equality predicates heqTyCon, heqClass, heqDataCon, @@ -224,8 +223,6 @@ wiredInTyCons = [ -- Units are not treated like other tuples, because then , vecElemTyCon , constraintKindTyCon , liftedTypeKindTyCon - , starKindTyCon - , unicodeStarKindTyCon ] mkWiredInTyConName :: BuiltInSyntax -> Module -> FastString -> Unique -> TyCon -> Name @@ -389,11 +386,8 @@ typeSymbolKindConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Symbol") constraintKindTyConName :: Name constraintKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Constraint") constraintKindTyConKey constraintKindTyCon -liftedTypeKindTyConName, starKindTyConName, unicodeStarKindTyConName - :: Name +liftedTypeKindTyConName :: Name liftedTypeKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "Type") liftedTypeKindTyConKey liftedTypeKindTyCon -starKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "*") starKindTyConKey starKindTyCon -unicodeStarKindTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "★") unicodeStarKindTyConKey unicodeStarKindTyCon runtimeRepTyConName, vecRepDataConName, tupleRepDataConName, sumRepDataConName :: Name runtimeRepTyConName = mkWiredInTyConName UserSyntax gHC_TYPES (fsLit "RuntimeRep") runtimeRepTyConKey runtimeRepTyCon @@ -1063,25 +1057,13 @@ mk_class tycon sc_pred sc_sel_id runtimeRepTy :: Type runtimeRepTy = mkTyConTy runtimeRepTyCon -liftedTypeKindTyCon, starKindTyCon, unicodeStarKindTyCon :: TyCon - -- Type synonyms; see Note [TYPE and RuntimeRep] in TysPrim -- type Type = tYPE 'LiftedRep --- type * = tYPE 'LiftedRep --- type * = tYPE 'LiftedRep -- Unicode variant - +liftedTypeKindTyCon :: TyCon liftedTypeKindTyCon = buildSynTyCon liftedTypeKindTyConName [] liftedTypeKind [] (tYPE liftedRepTy) -starKindTyCon = buildSynTyCon starKindTyConName - [] liftedTypeKind [] - (tYPE liftedRepTy) - -unicodeStarKindTyCon = buildSynTyCon unicodeStarKindTyConName - [] liftedTypeKind [] - (tYPE liftedRepTy) - runtimeRepTyCon :: TyCon runtimeRepTyCon = pcTyCon runtimeRepTyConName Nothing [] (vecRepDataCon : tupleRepDataCon : diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs index 6d940299e4..3c0d8f5327 100644 --- a/compiler/rename/RnEnv.hs +++ b/compiler/rename/RnEnv.hs @@ -13,7 +13,7 @@ module RnEnv ( lookupLocatedOccRn, lookupOccRn, lookupOccRn_maybe, lookupLocalOccRn_maybe, lookupInfoOccRn, lookupLocalOccThLvl_maybe, lookupLocalOccRn, - lookupTypeOccRn, lookupKindOccRn, + lookupTypeOccRn, lookupGlobalOccRn, lookupGlobalOccRn_maybe, lookupOccRn_overloaded, lookupGlobalOccRn_overloaded, lookupExactOcc, @@ -824,20 +824,6 @@ lookupLocalOccRn rdr_name Just name -> return name Nothing -> unboundName WL_LocalOnly rdr_name } -lookupKindOccRn :: RdrName -> RnM Name --- Looking up a name occurring in a kind -lookupKindOccRn rdr_name - | isVarOcc (rdrNameOcc rdr_name) -- See Note [Promoted variables in types] - = badVarInType rdr_name - | otherwise - = do { typeintype <- xoptM LangExt.TypeInType - ; if | typeintype -> lookupTypeOccRn rdr_name - -- With -XNoTypeInType, treat any usage of * in kinds as in scope - -- this is a dirty hack, but then again so was the old * kind. - | isStar rdr_name -> return starKindTyConName - | isUniStar rdr_name -> return unicodeStarKindTyConName - | otherwise -> lookupOccRn rdr_name } - -- lookupPromotedOccRn looks up an optionally promoted RdrName. lookupTypeOccRn :: RdrName -> RnM Name -- see Note [Demotion] @@ -846,16 +832,18 @@ lookupTypeOccRn rdr_name = badVarInType rdr_name | otherwise = do { mb_name <- lookupOccRn_maybe rdr_name - ; case mb_name of { - Just name -> return name ; - Nothing -> do { dflags <- getDynFlags - ; lookup_demoted rdr_name dflags } } } + ; case mb_name of + Just name -> return name + Nothing -> lookup_demoted rdr_name } -lookup_demoted :: RdrName -> DynFlags -> RnM Name -lookup_demoted rdr_name dflags +lookup_demoted :: RdrName -> RnM Name +lookup_demoted rdr_name | Just demoted_rdr <- demoteRdrName rdr_name -- Maybe it's the name of a *data* constructor = do { data_kinds <- xoptM LangExt.DataKinds + ; type_operators <- xoptM LangExt.TypeOperators + ; star_is_type <- xoptM LangExt.StarIsType + ; let star_info = starInfo (type_operators, star_is_type) rdr_name ; if data_kinds then do { mb_demoted_name <- lookupOccRn_maybe demoted_rdr ; case mb_demoted_name of @@ -873,7 +861,7 @@ lookup_demoted rdr_name dflags mb_demoted_name <- discardErrs $ lookupOccRn_maybe demoted_rdr ; let suggestion | isJust mb_demoted_name = suggest_dk - | otherwise = star_info + | otherwise = star_info ; unboundNameX WL_Any rdr_name suggestion } } | otherwise @@ -889,17 +877,6 @@ lookup_demoted rdr_name dflags , text "instead of" , quotes (ppr name) <> dot ] - star_info - | isStar rdr_name || isUniStar rdr_name - = if xopt LangExt.TypeInType dflags - then text "NB: With TypeInType, you must import" <+> - ppr rdr_name <+> text "from Data.Kind" - else empty - - | otherwise - = empty - - badVarInType :: RdrName -> RnM Name badVarInType rdr_name = do { addErr (text "Illegal promoted term variable in a type:" diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs index a53adf2cba..50841af818 100644 --- a/compiler/rename/RnSource.hs +++ b/compiler/rename/RnSource.hs @@ -1509,9 +1509,7 @@ rnTyClDecl (DataDecl { tcdLName = tycon, tcdTyVars = tyvars, ; bindHsQTyVars doc Nothing Nothing kvs tyvars $ \ tyvars' no_rhs_kvs -> do { (defn', fvs) <- rnDataDefn doc defn -- See Note [Complete user-supplied kind signatures] in HsDecls - ; typeintype <- xoptM LangExt.TypeInType - ; let cusk = hsTvbAllKinded tyvars' && - (not typeintype || no_rhs_kvs) + ; let cusk = hsTvbAllKinded tyvars' && no_rhs_kvs rn_info = DataDeclRn { tcdDataCusk = cusk , tcdFVs = fvs } ; traceRn "rndata" (ppr tycon <+> ppr cusk <+> ppr no_rhs_kvs) diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs index 1f08856142..3d60a9f6c3 100644 --- a/compiler/rename/RnTypes.hs +++ b/compiler/rename/RnTypes.hs @@ -53,7 +53,6 @@ import TcRnMonad import RdrName import PrelNames import TysPrim ( funTyConName ) -import TysWiredIn ( starKindTyConName, unicodeStarKindTyConName ) import Name import SrcLoc import NameSet @@ -341,9 +340,6 @@ rnImplicitBndrs bind_free_tvs ; traceRn "checkMixedVars2" $ vcat [ text "kvs_with_dups" <+> ppr kvs_with_dups , text "tvs_with_dups" <+> ppr tvs_with_dups ] - ; checkMixedVars kvs_with_dups tvs_with_dups - -- E.g. Either (Proxy (a :: k)) k - -- Here 'k' is used at kind level and type level ; bindLocalNamesFV vars $ thing_inside vars } @@ -395,35 +391,6 @@ f :: forall a. a -> (() => b) binds "a" and "b" This situation is now considered to be an error. See rnHsTyKi for case HsForAllTy Qualified. -Note [Dealing with *] -~~~~~~~~~~~~~~~~~~~~~ -As a legacy from the days when types and kinds were different, we use -the type * to mean what we now call GHC.Types.Type. The problem is that -* should associate just like an identifier, *not* a symbol. -Running example: the user has written - - T (Int, Bool) b + c * d - -At this point, we have a bunch of stretches of types - - [[T, (Int, Bool), b], [c], [d]] - -these are the [[LHsType Name]] and a bunch of operators - - [GHC.TypeLits.+, GHC.Types.*] - -Note that the * is GHC.Types.*. So, we want to rearrange to have - - [[T, (Int, Bool), b], [c, *, d]] - -and - - [GHC.TypeLits.+] - -as our lists. We can then do normal fixity resolution on these. The fixities -must come along for the ride just so that the list stays in sync with the -operators. - Note [QualTy in kinds] ~~~~~~~~~~~~~~~~~~~~~~ I was wondering whether QualTy could occur only at TypeLevel. But no, @@ -525,7 +492,7 @@ rnLHsTyKi env (L loc ty) rnHsTyKi :: RnTyKiEnv -> HsType GhcPs -> RnM (HsType GhcRn, FreeVars) rnHsTyKi env ty@(HsForAllTy { hst_bndrs = tyvars, hst_body = tau }) - = do { checkTypeInType env ty + = do { checkPolyKinds env ty ; bindLHsTyVarBndrs (rtke_ctxt env) (Just $ inTypeDoc ty) Nothing tyvars $ \ tyvars' -> do { (tau', fvs) <- rnLHsTyKi env tau @@ -534,7 +501,7 @@ rnHsTyKi env ty@(HsForAllTy { hst_bndrs = tyvars, hst_body = tau }) , fvs) } } rnHsTyKi env ty@(HsQualTy { hst_ctxt = lctxt, hst_body = tau }) - = do { checkTypeInType env ty -- See Note [QualTy in kinds] + = do { checkPolyKinds env ty -- See Note [QualTy in kinds] ; (ctxt', fvs1) <- rnTyKiContext env lctxt ; (tau', fvs2) <- rnLHsTyKi env tau ; return (HsQualTy { hst_xqual = noExt, hst_ctxt = ctxt' @@ -569,6 +536,7 @@ rnHsTyKi env (HsParTy _ ty) rnHsTyKi env (HsBangTy _ b ty) = do { (ty', fvs) <- rnLHsTyKi env ty ; return (HsBangTy noExt b ty', fvs) } + rnHsTyKi env ty@(HsRecTy _ flds) = do { let ctxt = rtke_ctxt env ; fls <- get_fields ctxt @@ -601,7 +569,7 @@ rnHsTyKi env listTy@(HsListTy _ ty) ; return (HsListTy noExt ty', fvs) } rnHsTyKi env t@(HsKindSig _ ty k) - = do { checkTypeInType env t + = do { checkPolyKinds env t ; kind_sigs_ok <- xoptM LangExt.KindSignatures ; unless kind_sigs_ok (badKindSigErr (rtke_ctxt env) ty) ; (ty', fvs1) <- rnLHsTyKi env ty @@ -629,70 +597,13 @@ rnHsTyKi env tyLit@(HsTyLit _ t) = do { data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env tyLit)) ; when (negLit t) (addErr negLitErr) - ; checkTypeInType env tyLit + ; checkPolyKinds env tyLit ; return (HsTyLit noExt t, emptyFVs) } where negLit (HsStrTy _ _) = False negLit (HsNumTy _ i) = i < 0 negLitErr = text "Illegal literal in type (type literals must not be negative):" <+> ppr tyLit -rnHsTyKi env overall_ty@(HsAppsTy _ tys) - = do { -- Step 1: Break up the HsAppsTy into symbols and non-symbol regions - let (non_syms, syms) = splitHsAppsTy tys - - -- Step 2: rename the pieces - ; (syms1, fvs1) <- mapFvRn (rnHsTyOp env overall_ty) syms - ; (non_syms1, fvs2) <- (mapFvRn . mapFvRn) (rnLHsTyKi env) non_syms - - -- Step 3: deal with *. See Note [Dealing with *] - ; let (non_syms2, syms2) = deal_with_star [] [] non_syms1 syms1 - - -- Step 4: collapse the non-symbol regions with HsAppTy - ; non_syms3 <- mapM deal_with_non_syms non_syms2 - - -- Step 5: assemble the pieces, using mkHsOpTyRn - ; L _ res_ty <- build_res_ty non_syms3 syms2 - - -- all done. Phew. - ; return (res_ty, fvs1 `plusFV` fvs2) } - where - -- See Note [Dealing with *] - deal_with_star :: [[LHsType GhcRn]] -> [Located Name] - -> [[LHsType GhcRn]] -> [Located Name] - -> ([[LHsType GhcRn]], [Located Name]) - deal_with_star acc1 acc2 - (non_syms1 : non_syms2 : non_syms) (L loc star : ops) - | star `hasKey` starKindTyConKey || star `hasKey` unicodeStarKindTyConKey - = deal_with_star acc1 acc2 - ((non_syms1 ++ L loc (HsTyVar noExt NotPromoted (L loc star)) - : non_syms2) : non_syms) - ops - deal_with_star acc1 acc2 (non_syms1 : non_syms) (op1 : ops) - = deal_with_star (non_syms1 : acc1) (op1 : acc2) non_syms ops - deal_with_star acc1 acc2 [non_syms] [] - = (reverse (non_syms : acc1), reverse acc2) - deal_with_star _ _ _ _ - = pprPanic "deal_with_star" (ppr overall_ty) - - -- collapse [LHsType GhcRn] to LHsType GhcRn by making applications - -- monadic only for failure - deal_with_non_syms :: [LHsType GhcRn] -> RnM (LHsType GhcRn) - deal_with_non_syms (non_sym : non_syms) = return $ mkHsAppTys non_sym non_syms - deal_with_non_syms [] = failWith (emptyNonSymsErr overall_ty) - - -- assemble a right-biased OpTy for use in mkHsOpTyRn - build_res_ty :: [LHsType GhcRn] -> [Located Name] -> RnM (LHsType GhcRn) - build_res_ty (arg1 : args) (op1 : ops) - = do { rhs <- build_res_ty args ops - ; fix <- lookupTyFixityRn op1 - ; res <- mkHsOpTyRn (\t1 t2 -> HsOpTy noExt t1 op1 t2) (unLoc op1) - fix arg1 rhs - ; let loc = combineSrcSpans (getLoc arg1) (getLoc rhs) - ; return (L loc res) - } - build_res_ty [arg] [] = return arg - build_res_ty _ _ = pprPanic "build_op_ty" (ppr overall_ty) - rnHsTyKi env (HsAppTy _ ty1 ty2) = do { (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 @@ -704,11 +615,14 @@ rnHsTyKi env t@(HsIParamTy _ n ty) ; return (HsIParamTy noExt n ty', fvs) } rnHsTyKi env t@(HsEqTy _ ty1 ty2) - = do { checkTypeInType env t + = do { checkPolyKinds env t ; (ty1', fvs1) <- rnLHsTyKi env ty1 ; (ty2', fvs2) <- rnLHsTyKi env ty2 ; return (HsEqTy noExt ty1' ty2', fvs1 `plusFV` fvs2) } +rnHsTyKi _ (HsStarTy _ isUni) + = return (HsStarTy noExt isUni, emptyFVs) + rnHsTyKi _ (HsSpliceTy _ sp) = rnSpliceType sp @@ -723,14 +637,14 @@ rnHsTyKi _ (XHsType (NHsCoreTy ty)) -- but I don't think it matters rnHsTyKi env ty@(HsExplicitListTy _ ip tys) - = do { checkTypeInType env ty + = do { checkPolyKinds env ty ; data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys ; return (HsExplicitListTy noExt ip tys', fvs) } rnHsTyKi env ty@(HsExplicitTupleTy _ tys) - = do { checkTypeInType env ty + = do { checkPolyKinds env ty ; data_kinds <- xoptM LangExt.DataKinds ; unless data_kinds (addErr (dataKindsErr env ty)) ; (tys', fvs) <- mapFvRn (rnLHsTyKi env) tys @@ -747,9 +661,7 @@ rnHsTyKi env (HsWildCardTy _) -------------- rnTyVar :: RnTyKiEnv -> RdrName -> RnM Name rnTyVar env rdr_name - = do { name <- if isRnKindLevel env - then lookupKindOccRn rdr_name - else lookupTypeOccRn rdr_name + = do { name <- lookupTypeOccRn rdr_name ; checkNamedWildCard env name ; return name } @@ -766,10 +678,7 @@ rnHsTyOp :: Outputable a rnHsTyOp env overall_ty (L loc op) = do { ops_ok <- xoptM LangExt.TypeOperators ; op' <- rnTyVar env op - ; unless (ops_ok - || op' == starKindTyConName - || op' == unicodeStarKindTyConName - || op' `hasKey` eqTyConKey) $ + ; unless (ops_ok || op' `hasKey` eqTyConKey) $ addErr (opTyErr op overall_ty) ; let l_op' = L loc op' ; return (l_op', unitFV op') } @@ -844,18 +753,18 @@ rnAnonWildCard ; return (AnonWildCard (L loc name)) } --------------- --- | Ensures either that we're in a type or that -XTypeInType is set -checkTypeInType :: Outputable ty +-- | Ensures either that we're in a type or that -XPolyKinds is set +checkPolyKinds :: Outputable ty => RnTyKiEnv -> ty -- ^ type -> RnM () -checkTypeInType env ty +checkPolyKinds env ty | isRnKindLevel env - = do { type_in_type <- xoptM LangExt.TypeInType - ; unless type_in_type $ + = do { polykinds <- xoptM LangExt.PolyKinds + ; unless polykinds $ addErr (text "Illegal kind:" <+> ppr ty $$ - text "Did you mean to enable TypeInType?") } -checkTypeInType _ _ = return () + text "Did you mean to enable PolyKinds?") } +checkPolyKinds _ _ = return () notInKinds :: Outputable ty => RnTyKiEnv @@ -863,7 +772,7 @@ notInKinds :: Outputable ty -> RnM () notInKinds env ty | isRnKindLevel env - = addErr (text "Illegal kind (even with TypeInType enabled):" <+> ppr ty) + = addErr (text "Illegal kind:" <+> ppr ty) notInKinds _ _ = return () {- ***************************************************** @@ -942,7 +851,6 @@ bindHsQTyVars doc mb_in_doc mb_assoc body_kv_occs hsq_bndrs thing_inside , text "bndr_kv_occs" <+> ppr bndr_kv_occs , text "wubble" <+> ppr ((kv_occs \\ bndrs) \\ bndr_kv_occs) ] - ; checkMixedVars kv_occs bndrs ; implicit_kv_nms <- mapM (newTyVarNameRn mb_assoc) implicit_kvs @@ -1050,20 +958,14 @@ In implementation terms Note [Variables used as both types and kinds] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In (checkMixedVars kvs tvs), we bind the type variables tvs, and kvs is the -set of free variables of the kinds in the scope of the binding. Here is one -typical example: +We bind the type variables tvs, and kvs is the set of free variables of the +kinds in the scope of the binding. Here is one typical example: forall a b. a -> (b::k) -> (c::a) Here, tvs will be {a,b}, and kvs {k,a}. -Without -XTypeInType we want to complain that `a` is used both -as a type and a kind. - -Specifically, check that there is no overlap between kvs and tvs -See typecheck/should_fail/T11963 for examples. -We must also make sure that kvs includes all of variables in the kinds of type +We must make sure that kvs includes all of variables in the kinds of type variable bindings. For instance: forall k (a :: k). Proxy a @@ -1071,8 +973,7 @@ variable bindings. For instance: If we only look in the body of the `forall` type, we will mistakenly conclude that kvs is {}. But in fact, the type variable `k` is also used as a kind variable in (a :: k), later in the binding. (This mistake lead to #14710.) -So tvs is {k,a} and kvs is {k}, so we must also reject this without the use -of -XTypeInType. +So tvs is {k,a} and kvs is {k}. NB: we do this only at the binding site of 'tvs'. -} @@ -1140,7 +1041,6 @@ collectAnonWildCards lty = go lty where go (L _ ty) = case ty of HsWildCardTy (AnonWildCard (L _ wc)) -> [wc] - HsAppsTy _ tys -> gos (mapMaybe (prefix_types_only . unLoc) tys) HsAppTy _ ty1 ty2 -> go ty1 `mappend` go ty2 HsFunTy _ ty1 ty2 -> go ty1 `mappend` go ty2 HsListTy _ ty -> go ty @@ -1165,14 +1065,11 @@ collectAnonWildCards lty = go lty HsSpliceTy{} -> mempty HsTyLit{} -> mempty HsTyVar{} -> mempty + HsStarTy{} -> mempty XHsType{} -> mempty gos = mconcat . map go - prefix_types_only (HsAppPrefix _ ty) = Just ty - prefix_types_only (HsAppInfix _ _) = Nothing - prefix_types_only (XAppType _) = Nothing - collectAnonWildCardsBndrs :: [LHsTyVarBndr GhcRn] -> [Name] collectAnonWildCardsBndrs ltvs = concatMap (go . unLoc) ltvs where @@ -1587,10 +1484,6 @@ opTyErr op overall_ty | otherwise = text "Use TypeOperators to allow operators in types" -emptyNonSymsErr :: HsType GhcPs -> SDoc -emptyNonSymsErr overall_ty - = text "Operator applied to too few arguments:" <+> ppr overall_ty - {- ************************************************************************ * * @@ -1829,7 +1722,6 @@ extract_lty t_or_k (L _ ty) acc HsRecTy _ flds -> foldrM (extract_lty t_or_k . cd_fld_type . unLoc) acc flds - HsAppsTy _ tys -> extract_apps t_or_k tys acc HsAppTy _ ty1 ty2 -> extract_lty t_or_k ty1 =<< extract_lty t_or_k ty2 acc HsListTy _ ty -> extract_lty t_or_k ty acc @@ -1849,6 +1741,7 @@ extract_lty t_or_k (L _ ty) acc HsExplicitListTy _ _ tys -> extract_ltys t_or_k tys acc HsExplicitTupleTy _ tys -> extract_ltys t_or_k tys acc HsTyLit _ _ -> return acc + HsStarTy _ _ -> return acc HsKindSig _ ty ki -> extract_lty t_or_k ty =<< extract_lkind ki acc HsForAllTy { hst_bndrs = tvs, hst_body = ty } @@ -1861,16 +1754,6 @@ extract_lty t_or_k (L _ ty) acc -- We deal with these separately in rnLHsTypeWithWildCards HsWildCardTy {} -> return acc -extract_apps :: TypeOrKind - -> [LHsAppType GhcPs] -> FreeKiTyVars -> RnM FreeKiTyVars -extract_apps t_or_k tys acc = foldrM (extract_app t_or_k) acc tys - -extract_app :: TypeOrKind -> LHsAppType GhcPs - -> FreeKiTyVarsWithDups -> RnM FreeKiTyVarsWithDups -extract_app t_or_k (L _ (HsAppInfix _ tv)) acc = extract_tv t_or_k tv acc -extract_app t_or_k (L _ (HsAppPrefix _ ty)) acc = extract_lty t_or_k ty acc -extract_app _ (L _ (XAppType _ )) _ = panic "extract_app" - extractHsTvBndrs :: [LHsTyVarBndr GhcPs] -> FreeKiTyVarsWithDups -- Free in body -> RnM FreeKiTyVarsWithDups -- Free in result @@ -1906,7 +1789,6 @@ extract_hs_tv_bndrs tv_bndrs , text "body_kvs" <+> ppr body_kvs , text "all_kv_occs" <+> ppr all_kv_occs , text "tv_bndr_rdrs" <+> ppr tv_bndr_rdrs ] - ; checkMixedVars all_kv_occs tv_bndr_rdrs ; return $ FKTV (filterOut (`elemRdr` tv_bndr_rdrs) all_kv_occs @@ -1940,17 +1822,3 @@ nubL = nubBy eqLocated elemRdr :: Located RdrName -> [Located RdrName] -> Bool elemRdr x = any (eqLocated x) - --- Check for type variables that are also used as kinds without the use of --- -XTypeInType. See Note [Variables used as both types and kinds]. -checkMixedVars :: [Located RdrName] -> [Located RdrName] -> RnM () -checkMixedVars kvs tvs - = do { type_in_type <- xoptM LangExt.TypeInType - ; unless type_in_type $ - mapM_ check kvs } - where - check kv = when (kv `elemRdr` tvs) $ - addErrAt (getLoc kv) $ - vcat [ text "Variable" <+> quotes (ppr kv) - <+> text "used as both a kind and a type" - , text "Did you intend to use TypeInType?" ] diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs index 327876804a..1795131c79 100644 --- a/compiler/typecheck/TcDeriv.hs +++ b/compiler/typecheck/TcDeriv.hs @@ -968,11 +968,11 @@ generated instance of: instance (k ~ *) => Functor (T k) where -But this does not typecheck as the result of a -XTypeInType design decision: -kind equalities are not allowed to be bound in types, only terms. But in -essence, the two instance declarations are entirely equivalent, since even -though (T k) matches any kind k, the only possibly value for k is *, since -anything else is ill-typed. As a result, we can just as comfortably use (T *). +But this does not typecheck by design: kind equalities are not allowed to be +bound in types, only terms. But in essence, the two instance declarations are +entirely equivalent, since even though (T k) matches any kind k, the only +possibly value for k is *, since anything else is ill-typed. As a result, we can +just as comfortably use (T *). Another way of thinking about is: deriving clauses often infer constraints. For example: @@ -1064,8 +1064,8 @@ mentions other type variables: data family Fam (f :: * -> *) (a :: *) newtype instance Fam f (Const a f) = Fam (f a) deriving Functor -With -XTypeInType, it is also possible to define kind synonyms, and they can -mention other types in a datatype declaration. For example, +It is also possible to define kind synonyms, and they can mention other types in +a datatype declaration. For example, type Const a b = a newtype T f (a :: Const * f) = T (f a) deriving Functor diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index fb8f62fa27..f29dce9e85 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -800,6 +800,11 @@ tc_hs_type mode rn_ty@(HsEqTy _ ty1 ty2) exp_kind ; let ty' = mkNakedTyConApp eq_tc [kind1, ty1', ty2''] ; checkExpectedKind rn_ty ty' constraintKind exp_kind } +tc_hs_type _ rn_ty@(HsStarTy _ _) exp_kind + -- Desugaring 'HsStarTy' to 'Data.Kind.Type' here means that we don't have to + -- handle it in 'coreView' and 'tcView'. + = checkExpectedKind rn_ty liftedTypeKind liftedTypeKind exp_kind + --------- Literals tc_hs_type _ rn_ty@(HsTyLit _ (HsNumTy _ n)) exp_kind = do { checkWiredInTyCon typeNatKindCon @@ -824,10 +829,6 @@ tc_hs_type _ (HsWildCardTy wc) exp_kind -- we still need it to establish Note [The tcType invariant] } --- disposed of by renamer -tc_hs_type _ ty@(HsAppsTy {}) _ - = pprPanic "tc_hs_tyep HsAppsTy" (ppr ty) - tcWildCardOcc :: HsWildCardInfo -> Kind -> TcM TcType tcWildCardOcc wc_info exp_kind = do { wc_tv <- tcLookupTyVar (wildCardName wc_info) @@ -1137,9 +1138,6 @@ tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon ; tc <- get_loopy_tc name tc_tc ; handle_tyfams tc tc_tc } -- mkNakedTyConApp: see Note [Type-checking inside the knot] - -- NB: we really should check if we're at the kind level - -- and if the tycon is promotable if -XNoTypeInType is set. - -- But this is a terribly large amount of work! Not worth it. AGlobal (ATyCon tc) -> do { check_tc tc @@ -1149,13 +1147,9 @@ tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon -> do { data_kinds <- xoptM LangExt.DataKinds ; unless (data_kinds || specialPromotedDc dc) $ promotionErr name NoDataKindsDC - ; type_in_type <- xoptM LangExt.TypeInType - ; unless ( type_in_type || - ( isTypeLevel (mode_level mode) && - isLegacyPromotableDataCon dc ) || - ( isKindLevel (mode_level mode) && - specialPromotedDc dc ) ) $ - promotionErr name NoTypeInTypeDC + ; when (isFamInstTyCon (dataConTyCon dc)) $ + -- see Trac #15245 + promotionErr name FamDataConPE ; let tc = promoteDataCon dc ; return (mkNakedTyConApp tc [], tyConKind tc) } @@ -1164,16 +1158,11 @@ tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon _ -> wrongThingErr "type" thing name } where check_tc :: TyCon -> TcM () - check_tc tc = do { type_in_type <- xoptM LangExt.TypeInType - ; data_kinds <- xoptM LangExt.DataKinds + check_tc tc = do { data_kinds <- xoptM LangExt.DataKinds ; unless (isTypeLevel (mode_level mode) || data_kinds || isKindTyCon tc) $ - promotionErr name NoDataKindsTC - ; unless (isTypeLevel (mode_level mode) || - type_in_type || - isLegacyPromotableTyCon tc) $ - promotionErr name NoTypeInTypeTC } + promotionErr name NoDataKindsTC } -- if we are type-checking a type family tycon, we must instantiate -- any invisible arguments right away. Otherwise, we get #11246 @@ -1584,15 +1573,9 @@ kcLHsQTyVars name flav cusk , hsq_dependent = dep_names } , hsq_explicit = hs_tvs }) thing_inside | cusk - = do { typeintype <- xoptM LangExt.TypeInType - ; let m_kind - | typeintype = Nothing - | otherwise = Just liftedTypeKind - -- without -XTypeInType, default all kind variables to have kind * - - ; (scoped_kvs, (tc_tvs, (res_kind, stuff))) + = do { (scoped_kvs, (tc_tvs, (res_kind, stuff))) <- solveEqualities $ - tcImplicitTKBndrsX newSkolemTyVar m_kind skol_info kv_ns $ + tcImplicitTKBndrsX newSkolemTyVar skol_info kv_ns $ kcLHsTyVarBndrs cusk open_fam skol_info hs_tvs thing_inside -- Now, because we're in a CUSK, quantify over the mentioned @@ -1649,17 +1632,10 @@ kcLHsQTyVars name flav cusk ; return (tycon, stuff) } | otherwise - = do { typeintype <- xoptM LangExt.TypeInType - - -- if -XNoTypeInType and we know all the implicits are kind vars, - -- just give the kind *. This prevents test - -- dependent/should_fail/KindLevelsB from compiling, as it should - ; let default_kind - | typeintype = Nothing - | otherwise = Just liftedTypeKind - -- Why newSigTyVar? See Note [Kind generalisation and sigTvs] - ; (scoped_kvs, (tc_tvs, (res_kind, stuff))) - <- kcImplicitTKBndrs kv_ns default_kind $ + = do { (scoped_kvs, (tc_tvs, (res_kind, stuff))) + -- Why kcImplicitTKBndrs which uses newSigTyVar? + -- See Note [Kind generalisation and sigTvs] + <- kcImplicitTKBndrs kv_ns $ kcLHsTyVarBndrs cusk open_fam skol_info hs_tvs thing_inside ; let -- NB: Don't add scoped_kvs to tyConTyVars, because they @@ -1769,17 +1745,16 @@ tcImplicitTKBndrs :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) -tcImplicitTKBndrs = tcImplicitTKBndrsX newSkolemTyVar Nothing +tcImplicitTKBndrs = tcImplicitTKBndrsX newSkolemTyVar -- | Like 'tcImplicitTKBndrs', but uses 'newSigTyVar' to create tyvars tcImplicitTKBndrsSig :: SkolemInfo -> [Name] -> TcM a -> TcM ([TcTyVar], a) -tcImplicitTKBndrsSig = tcImplicitTKBndrsX newSigTyVar Nothing +tcImplicitTKBndrsSig = tcImplicitTKBndrsX newSigTyVar tcImplicitTKBndrsX :: (Name -> Kind -> TcM TcTyVar) -- new_tv function - -> Maybe Kind -- Just k <=> assign all names this kind -> SkolemInfo -> [Name] -> TcM a @@ -1793,7 +1768,7 @@ tcImplicitTKBndrsX :: (Name -> Kind -> TcM TcTyVar) -- new_tv function -- -- * Returned TcTyVars have zonked kinds -- See Note [Keeping scoped variables in order: Implicit] -tcImplicitTKBndrsX new_tv m_kind skol_info tv_names thing_inside +tcImplicitTKBndrsX new_tv skol_info tv_names thing_inside | null tv_names -- Short cut for the common case where there -- are no implicit type variables to bind = do { result <- solveLocalEqualities thing_inside @@ -1803,7 +1778,7 @@ tcImplicitTKBndrsX new_tv m_kind skol_info tv_names thing_inside = do { (skol_tvs, result) <- solveLocalEqualities $ checkTvConstraints skol_info Nothing $ - do { tv_pairs <- mapM (tcHsTyVarName new_tv m_kind) tv_names + do { tv_pairs <- mapM (tcHsTyVarName new_tv Nothing) tv_names ; let must_scope_tvs = [ tv | (tv, False) <- tv_pairs ] ; result <- tcExtendTyVarEnv must_scope_tvs $ thing_inside @@ -1821,13 +1796,11 @@ tcImplicitTKBndrsX new_tv m_kind skol_info tv_names thing_inside -- kind checking. Uses SigTvs, as per Note [Use SigTvs in kind-checking pass] -- in TcTyClsDecls. kcImplicitTKBndrs :: [Name] -- of the vars - -> Maybe Kind -- Just k <=> use k as the kind for all vars - -- Nothing <=> use a meta-tyvar -> TcM a -> TcM ([TcTyVar], a) -- returns the tyvars created -- these are *not* dependency ordered -kcImplicitTKBndrs var_ns m_kind thing_inside - = do { tkvs_pairs <- mapM (tcHsTyVarName newSigTyVar m_kind) var_ns +kcImplicitTKBndrs var_ns thing_inside + = do { tkvs_pairs <- mapM (tcHsTyVarName newSigTyVar Nothing) var_ns ; let must_scope_tkvs = [ tkv | (tkv, False) <- tkvs_pairs ] ; result <- tcExtendTyVarEnv must_scope_tkvs $ thing_inside @@ -2750,8 +2723,6 @@ promotionErr name err FamDataConPE -> text "it comes from a data family instance" NoDataKindsTC -> text "perhaps you intended to use DataKinds" NoDataKindsDC -> text "perhaps you intended to use DataKinds" - NoTypeInTypeTC -> text "perhaps you intended to use TypeInType" - NoTypeInTypeDC -> text "perhaps you intended to use TypeInType" PatSynPE -> text "pattern synonyms cannot be promoted" PatSynExPE -> sep [ text "the existential variables of a pattern synonym" , text "signature do not scope over the pattern" ] @@ -2802,19 +2773,16 @@ reportFloatingKvs tycon_name flav all_tvs bad_tvs ; bad_tvs <- mapM zonkTcTyVarToTyVar bad_tvs ; let (tidy_env, tidy_all_tvs) = tidyOpenTyCoVars emptyTidyEnv all_tvs tidy_bad_tvs = map (tidyTyVarOcc tidy_env) bad_tvs - ; typeintype <- xoptM LangExt.TypeInType - ; mapM_ (report typeintype tidy_all_tvs) tidy_bad_tvs } + ; mapM_ (report tidy_all_tvs) tidy_bad_tvs } where - report typeintype tidy_all_tvs tidy_bad_tv + report tidy_all_tvs tidy_bad_tv = addErr $ vcat [ text "Kind variable" <+> quotes (ppr tidy_bad_tv) <+> text "is implicitly bound in" <+> ppr flav , quotes (ppr tycon_name) <> comma <+> text "but does not appear as the kind of any" , text "of its type variables. Perhaps you meant" - , text "to bind it" <+> ppWhen (not typeintype) - (text "(with TypeInType)") <+> - text "explicitly somewhere?" + , text "to bind it explicitly somewhere?" , ppWhen (not (null tidy_all_tvs)) $ hang (text "Type variables with inferred kinds:") 2 (ppr_tv_bndrs tidy_all_tvs) ] diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs index d09675778d..13b91d51cc 100644 --- a/compiler/typecheck/TcInstDcls.hs +++ b/compiler/typecheck/TcInstDcls.hs @@ -685,7 +685,7 @@ tcDataFamInstDecl mb_clsinfo -- Deal with any kind signature. -- See also Note [Arity of data families] in FamInstEnv ; (extra_tcbs, final_res_kind) <- tcDataKindSig full_tcbs res_kind' - ; checkTc (tcIsStarKind final_res_kind) (badKindSig True res_kind') + ; checkTc (tcIsLiftedTypeKind final_res_kind) (badKindSig True res_kind') ; let extra_pats = map (mkTyVarTy . binderVar) extra_tcbs all_pats = pats' `chkAppend` extra_pats @@ -727,7 +727,7 @@ tcDataFamInstDecl mb_clsinfo ; checkValidFamPats mb_clsinfo fam_tc tvs' [] pats' extra_pats pp_hs_pats -- Result kind must be '*' (otherwise, we have too few patterns) - ; checkTc (tcIsStarKind final_res_kind) $ + ; checkTc (tcIsLiftedTypeKind final_res_kind) $ tooFewParmsErr (tyConArity fam_tc) ; checkValidTyCon rep_tc diff --git a/compiler/typecheck/TcMType.hs b/compiler/typecheck/TcMType.hs index 87a9fa395d..1f7f98845f 100644 --- a/compiler/typecheck/TcMType.hs +++ b/compiler/typecheck/TcMType.hs @@ -1106,7 +1106,7 @@ defaultTyVar default_kind tv -- It takes an (unconstrained) meta tyvar and defaults it. -- Works only on vars of type *; for other kinds, it issues an error. default_kind_var kv - | isStarKind (tyVarKind kv) + | isLiftedTypeKind (tyVarKind kv) = do { traceTc "Defaulting a kind var to *" (ppr kv) ; writeMetaTyVar kv liftedTypeKind } | otherwise diff --git a/compiler/typecheck/TcPatSyn.hs b/compiler/typecheck/TcPatSyn.hs index f43072f59b..fdb9ead605 100644 --- a/compiler/typecheck/TcPatSyn.hs +++ b/compiler/typecheck/TcPatSyn.hs @@ -203,7 +203,7 @@ and it not straightforward to implement, because by the time we see the problem, simplifyInfer has already skolemised 's'.) This stuff can only happen in the presence of view patterns, with -TypeInType, so it's a bit of a corner case. +PolyKinds, so it's a bit of a corner case. Note [Coercions that escape] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs index 73b15a5252..d13941d9ec 100644 --- a/compiler/typecheck/TcRnTypes.hs +++ b/compiler/typecheck/TcRnTypes.hs @@ -1106,8 +1106,6 @@ data PromotionErr -- See Note [Recursion and promoting data constructors] in TcTyClsDecls | NoDataKindsTC -- -XDataKinds not enabled (for a tycon) | NoDataKindsDC -- -XDataKinds not enabled (for a datacon) - | NoTypeInTypeTC -- -XTypeInType not enabled (for a tycon) - | NoTypeInTypeDC -- -XTypeInType not enabled (for a datacon) instance Outputable TcTyThing where -- Debugging only ppr (AGlobal g) = ppr g @@ -1260,8 +1258,6 @@ instance Outputable PromotionErr where ppr RecDataConPE = text "RecDataConPE" ppr NoDataKindsTC = text "NoDataKindsTC" ppr NoDataKindsDC = text "NoDataKindsDC" - ppr NoTypeInTypeTC = text "NoTypeInTypeTC" - ppr NoTypeInTypeDC = text "NoTypeInTypeDC" pprTcTyThingCategory :: TcTyThing -> SDoc pprTcTyThingCategory (AGlobal thing) = pprTyThingCategory thing @@ -1279,8 +1275,6 @@ pprPECategory FamDataConPE = text "Data constructor" pprPECategory RecDataConPE = text "Data constructor" pprPECategory NoDataKindsTC = text "Type constructor" pprPECategory NoDataKindsDC = text "Data constructor" -pprPECategory NoTypeInTypeTC = text "Type constructor" -pprPECategory NoTypeInTypeDC = text "Data constructor" {- ************************************************************************ diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs index 5bef07f369..b4d9d46513 100644 --- a/compiler/typecheck/TcSplice.hs +++ b/compiler/typecheck/TcSplice.hs @@ -1720,8 +1720,8 @@ reifyFamilyInstance is_poly_tvs inst@(FamInst { fi_flavor = flavor ------------------------------ reifyType :: TyCoRep.Type -> TcM TH.Type -- Monadic only because of failure -reifyType ty | tcIsStarKind ty = return TH.StarT - -- Make sure to use tcIsStarKind here, since we don't want to confuse it +reifyType ty | tcIsLiftedTypeKind ty = return TH.StarT + -- Make sure to use tcIsLiftedTypeKind here, since we don't want to confuse it -- with Constraint (#14869). reifyType ty@(ForAllTy {}) = reify_for_all ty reifyType (LitTy t) = do { r <- reifyTyLit t; return (TH.LitT r) } diff --git a/compiler/typecheck/TcTyClsDecls.hs b/compiler/typecheck/TcTyClsDecls.hs index 7e523a7673..729be95796 100644 --- a/compiler/typecheck/TcTyClsDecls.hs +++ b/compiler/typecheck/TcTyClsDecls.hs @@ -774,7 +774,7 @@ kcConDecl (ConDeclGADT { con_names = names -- for the type constructor T addErrCtxt (dataConCtxtName names) $ discardResult $ - kcImplicitTKBndrs implicit_tkv_nms Nothing $ + kcImplicitTKBndrs implicit_tkv_nms $ kcExplicitTKBndrs explicit_tkv_nms $ do { _ <- tcHsMbContext cxt ; mapM_ (tcHsOpenType . getBangType) (hsConDeclArgTys args) @@ -1019,7 +1019,7 @@ tcFamDecl1 parent (FamilyDecl { fdInfo = fam_info, fdLName = tc_lname@(L _ tc_na -- Data families might have a variable return kind. -- See See Note [Arity of data families] in FamInstEnv. ; (extra_binders, final_res_kind) <- tcDataKindSig binders res_kind - ; checkTc (tcIsStarKind final_res_kind + ; checkTc (tcIsLiftedTypeKind final_res_kind || isJust (tcGetCastedTyVar_maybe final_res_kind)) (badKindSig False res_kind) @@ -1171,7 +1171,7 @@ tcDataDefn roles_info ; let hsc_src = tcg_src tcg_env ; (extra_bndrs, final_res_kind) <- tcDataKindSig tycon_binders res_kind ; unless (mk_permissive_kind hsc_src cons) $ - checkTc (tcIsStarKind final_res_kind) (badKindSig True res_kind) + checkTc (tcIsLiftedTypeKind final_res_kind) (badKindSig True res_kind) ; let final_bndrs = tycon_binders `chkAppend` extra_bndrs roles = roles_info tc_name @@ -1563,7 +1563,7 @@ kcFamTyPats :: TcTyCon -> TcM () kcFamTyPats tc_fam_tc tv_names arg_pats kind_checker = discardResult $ - kcImplicitTKBndrs tv_names Nothing $ + kcImplicitTKBndrs tv_names $ do { let loc = nameSrcSpan name lhs_fun = L loc (HsTyVar noExt NotPromoted (L loc name)) -- lhs_fun is for error messages only @@ -2672,32 +2672,6 @@ checkValidDataCon dflags existential_ok tc con ; checkTc (existential_ok || isVanillaDataCon con) (badExistential con) - ; typeintype <- xoptM LangExt.TypeInType - ; let (_, _, eq_specs, _, _, _) = dataConFullSig con - -- dataConEqSpec retrieves both the real GADT equalities - -- plus any user-written GADT-like equalities. But we don't - -- want anything user-written. If we don't exclude user-written - -- ones, test case polykinds/T13391a fails. - - invisible_gadt_eq_specs = filter is_invisible_eq_spec eq_specs - univ_tvs = dataConUnivTyVars con - tc_bndrs = tyConBinders tc - - vis_map :: VarEnv ArgFlag - vis_map = zipVarEnv univ_tvs (map tyConBinderArgFlag tc_bndrs) - - -- See Note [Wrong visibility for GADTs] for why we have to build the map - -- above instead of just looking at the datacon tyvar binder - is_invisible_eq_spec eq_spec - = isInvisibleArgFlag arg_flag - where - eq_tv = eqSpecTyVar eq_spec - arg_flag = expectJust "checkValidDataCon" $ - lookupVarEnv vis_map eq_tv - - ; checkTc (typeintype || null invisible_gadt_eq_specs) - (badGADT con invisible_gadt_eq_specs) - -- Check that UNPACK pragmas and bangs work out -- E.g. reject data T = MkT {-# UNPACK #-} Int -- No "!" -- data T = MkT {-# UNPACK #-} !a -- Can't unpack @@ -3506,15 +3480,6 @@ badExistential con 2 (vcat [ ppr con <+> dcolon <+> ppr (dataConUserType con) , parens $ text "Enable ExistentialQuantification or GADTs to allow this" ]) -badGADT :: DataCon -> [EqSpec] -> SDoc -badGADT con eq_specs - = hang (text "Data constructor" <+> quotes (ppr con) <+> - text "constrains the choice of kind parameter" <> plural eq_specs <> colon) - 2 (vcat (map ppr_eq_spec eq_specs)) $$ - text "Use TypeInType to allow this" - where - ppr_eq_spec eq_spec = ppr (eqSpecTyVar eq_spec) <+> char '~' <+> ppr (eqSpecType eq_spec) - badStupidTheta :: Name -> SDoc badStupidTheta tc_name = text "A data type declared in GADT style cannot have a context:" <+> quotes (ppr tc_name) diff --git a/compiler/types/Kind.hs b/compiler/types/Kind.hs index 58e38f267e..0ce6bfe7e0 100644 --- a/compiler/types/Kind.hs +++ b/compiler/types/Kind.hs @@ -13,8 +13,7 @@ module Kind ( isConstraintKindCon, classifiesTypeWithValues, - isStarKind, isStarKindSynonymTyCon, - tcIsStarKind, + tcIsLiftedTypeKind, isKindLevPoly ) where @@ -40,7 +39,7 @@ import Util * * ************************************************************************ -Note [Kind Constraint and kind *] +Note [Kind Constraint and kind Type] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The kind Constraint is the kind of classes and other type constraints. The special thing about types of kind Constraint is that @@ -51,16 +50,16 @@ The special thing about types of kind Constraint is that to f. However, once type inference is over, there is *no* distinction between -Constraint and *. Indeed we can have coercions between the two. Consider +Constraint and Type. Indeed we can have coercions between the two. Consider class C a where op :: a -> a For this single-method class we may generate a newtype, which in turn generates an axiom witnessing C a ~ (a -> a) -so on the left we have Constraint, and on the right we have *. +so on the left we have Constraint, and on the right we have Type. See Trac #7451. -Bottom line: although '*' and 'Constraint' are distinct TyCons, with +Bottom line: although 'Type' and 'Constraint' are distinct TyCons, with distinct uniques, they are treated as equal at all times except during type inference. -} @@ -98,8 +97,8 @@ returnsConstraintKind = returnsTyCon constraintKindTyConKey -- E.g. True of TYPE k, TYPE (F Int) -- False of TYPE 'LiftedRep isKindLevPoly :: Kind -> Bool -isKindLevPoly k = ASSERT2( isStarKind k || _is_type, ppr k ) - -- the isStarKind check is necessary b/c of Constraint +isKindLevPoly k = ASSERT2( isLiftedTypeKind k || _is_type, ppr k ) + -- the isLiftedTypeKind check is necessary b/c of Constraint go k where go ty | Just ty' <- coreView ty = go ty' @@ -135,21 +134,9 @@ classifiesTypeWithValues = isTYPE (const True) -- | Is this kind equivalent to @*@? -- -- This considers 'Constraint' to be distinct from @*@. For a version that --- treats them as the same type, see 'isStarKind'. -tcIsStarKind :: Kind -> Bool -tcIsStarKind = tcIsTYPE is_lifted +-- treats them as the same type, see 'isLiftedTypeKind'. +tcIsLiftedTypeKind :: Kind -> Bool +tcIsLiftedTypeKind = tcIsTYPE is_lifted where is_lifted (TyConApp lifted_rep []) = lifted_rep `hasKey` liftedRepDataConKey is_lifted _ = False - --- | Is this kind equivalent to @*@? --- --- This considers 'Constraint' to be the same as @*@. For a version that --- treats them as different types, see 'tcIsStarKind'. -isStarKind :: Kind -> Bool -isStarKind = isLiftedTypeKind - -- See Note [Kind Constraint and kind *] - --- | Is the tycon @Constraint@? -isStarKindSynonymTyCon :: TyCon -> Bool -isStarKindSynonymTyCon tc = tc `hasKey` constraintKindTyConKey diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs index bd10ac8cf3..362be33c03 100644 --- a/compiler/types/TyCoRep.hs +++ b/compiler/types/TyCoRep.hs @@ -801,6 +801,7 @@ tcIsTYPE _ _ = False -- | This version considers Constraint to be the same as *. Returns True -- if the argument is equivalent to Type/Constraint and False otherwise. +-- See Note [Kind Constraint and kind Type] isLiftedTypeKind :: Kind -> Bool isLiftedTypeKind = isTYPE is_lifted where diff --git a/compiler/types/TyCon.hs b/compiler/types/TyCon.hs index 230cec7c6c..2d9e53060f 100644 --- a/compiler/types/TyCon.hs +++ b/compiler/types/TyCon.hs @@ -2032,18 +2032,14 @@ isKindTyCon tc = getUnique tc `elementOfUniqSet` kindTyConKeys -- -XDataKinds. kindTyConKeys :: UniqSet Unique kindTyConKeys = unionManyUniqSets - ( mkUniqSet [ liftedTypeKindTyConKey, starKindTyConKey, unicodeStarKindTyConKey - , constraintKindTyConKey, tYPETyConKey ] + ( mkUniqSet [ liftedTypeKindTyConKey, constraintKindTyConKey, tYPETyConKey ] : map (mkUniqSet . tycon_with_datacons) [ runtimeRepTyCon , vecCountTyCon, vecElemTyCon ] ) where tycon_with_datacons tc = getUnique tc : map getUnique (tyConDataCons tc) isLiftedTypeKindTyConName :: Name -> Bool -isLiftedTypeKindTyConName - = (`hasKey` liftedTypeKindTyConKey) <||> - (`hasKey` starKindTyConKey) <||> - (`hasKey` unicodeStarKindTyConKey) +isLiftedTypeKindTyConName = (`hasKey` liftedTypeKindTyConKey) -- | Identifies implicit tycons that, in particular, do not go into interface -- files (because they are implicitly reconstructed when the interface is diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs index 8450cd2f84..963fad4068 100644 --- a/compiler/types/Type.hs +++ b/compiler/types/Type.hs @@ -340,7 +340,7 @@ coreView (TyConApp tc tys) | Just (tenv, rhs, tys') <- expandSynTyCon_maybe tc t -- partially-applied type constructor; indeed, usually will! coreView (TyConApp tc []) -- At the Core level, Constraint = Type - | isStarKindSynonymTyCon tc + | isConstraintKindCon tc = Just liftedTypeKind coreView _ = Nothing @@ -2298,13 +2298,14 @@ nonDetCmpTypesX _ [] _ = LT nonDetCmpTypesX _ _ [] = GT ------------- --- | Compare two 'TyCon's. NB: This should /never/ see the "star synonyms", --- as recognized by Kind.isStarKindSynonymTyCon. See Note --- [Kind Constraint and kind *] in Kind. +-- | Compare two 'TyCon's. NB: This should /never/ see 'Constraint' (as +-- recognized by Kind.isConstraintKindCon) which is considered a synonym for +-- 'Type' in Core. +-- See Note [Kind Constraint and kind Type] in Kind. -- See Note [nonDetCmpType nondeterminism] nonDetCmpTc :: TyCon -> TyCon -> Ordering nonDetCmpTc tc1 tc2 - = ASSERT( not (isStarKindSynonymTyCon tc1) && not (isStarKindSynonymTyCon tc2) ) + = ASSERT( not (isConstraintKindCon tc1) && not (isConstraintKindCon tc2) ) u1 `nonDetCmpUnique` u2 where u1 = tyConUnique tc1 diff --git a/compiler/types/Unify.hs b/compiler/types/Unify.hs index 220865ef89..9833f8effa 100644 --- a/compiler/types/Unify.hs +++ b/compiler/types/Unify.hs @@ -889,7 +889,7 @@ unify_ty env ty1 (TyVarTy tv2) kco unify_ty env ty1 ty2 _kco | Just (tc1, tys1) <- mb_tc_app1 , Just (tc2, tys2) <- mb_tc_app2 - , tc1 == tc2 || (tcIsStarKind ty1 && tcIsStarKind ty2) + , tc1 == tc2 || (tcIsLiftedTypeKind ty1 && tcIsLiftedTypeKind ty2) = if isInjectiveTyCon tc1 Nominal then unify_tys env tys1 tys2 else do { let inj | isTypeFamilyTyCon tc1 diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index 2c96ddaba0..4df9adfe84 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -28,7 +28,7 @@ module Outputable ( semi, comma, colon, dcolon, space, equals, dot, vbar, arrow, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt, lparen, rparen, lbrack, rbrack, lbrace, rbrace, underscore, - blankLine, forAllLit, kindStar, bullet, + blankLine, forAllLit, kindType, bullet, (<>), (<+>), hcat, hsep, ($$), ($+$), vcat, sep, cat, @@ -91,7 +91,7 @@ import GhcPrelude import {-# SOURCE #-} DynFlags( DynFlags, hasPprDebug, hasNoDebugOutput, targetPlatform, pprUserLength, pprCols, - useUnicode, useUnicodeSyntax, + useUnicode, useUnicodeSyntax, useStarIsType, shouldUseColor, unsafeGlobalDynFlags, shouldUseHexWordLiterals ) import {-# SOURCE #-} Module( UnitId, Module, ModuleName, moduleName ) @@ -650,8 +650,11 @@ rbrace = docToSDoc $ Pretty.rbrace forAllLit :: SDoc forAllLit = unicodeSyntax (char '∀') (text "forall") -kindStar :: SDoc -kindStar = unicodeSyntax (char '★') (char '*') +kindType :: SDoc +kindType = sdocWithDynFlags $ \dflags -> + if useStarIsType dflags + then unicodeSyntax (char '★') (char '*') + else text "Type" bullet :: SDoc bullet = unicode (char '•') (char '*') diff --git a/docs/users_guide/8.6.1-notes.rst b/docs/users_guide/8.6.1-notes.rst index d7ba6ed542..147558e139 100644 --- a/docs/users_guide/8.6.1-notes.rst +++ b/docs/users_guide/8.6.1-notes.rst @@ -49,6 +49,11 @@ Language See :ref:`deriving-via` for more information. +- A new :extension:`StarIsType` language extension has been added which controls + whether ``*`` is parsed as ``Data.Kind.Type`` or a regular type operator. + :extension:`StarIsType` is enabled by default and disabled by + :extension:`TypeOperators`. + - GHC now permits the use of a wildcard type as the context of a standalone ``deriving`` declaration with the use of the :extension:`PartialTypeSignatures` language extension. For instance, this @@ -98,24 +103,27 @@ Language See :ref:`Numeric underscores <numeric-underscores>` for the full details. -- GHC is now more diligent about catching illegal uses of kind polymorphism. - For instance, this used to be accepted without :extension:`PolyKinds`: :: +- CUSKs now require all kind variables to be explicitly quantified. This was + already the case with :extension:`TypeInType`, but now :extension:`PolyKinds` + also exhibits this behavior. This means that the following example is no + longer considered to have a CUSK:: - class C a where - c :: Proxy (x :: a) + data T1 :: k -> Type -- No CUSK: `k` is not explicitly quantified - Despite the fact that ``a`` is used as a kind variable in the type signature - for ``c``. This is now an error unless :extension:`PolyKinds` is explicitly - enabled. +- Functionality of :extension:`TypeInType` has been subsumed by + :extension:`PolyKinds`, and it is now merely a shorthand for + :extension:`PolyKinds`, :extension:`DataKinds`, and :extension:`NoStarIsType`. + The users are advised to avoid :extension:`TypeInType` due to its misleading + name: the ``Type :: Type`` axiom holds regardless of whether it is enabled. - Moreover, GHC 8.4 would accept the following without the use of - :extension:`TypeInType` (or even :extension:`PolyKinds`!): :: +- GHC has become more diligent about catching illegal uses of kind polymorphism. + For instance, GHC 8.4 would accept the following without the use of + :extension:`PolyKinds`:: f :: forall k (a :: k). Proxy a f = Proxy - Despite the fact that ``k`` is used as both a type and kind variable. This is - now an error unless :extension:`TypeInType` is explicitly enabled. + This is now an error unless :extension:`PolyKinds` is enabled. Compiler ~~~~~~~~ diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 24ae3bcbdc..6d7cb1d09a 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -148,24 +148,25 @@ stores a pointer. GHC currently does not support this variety of ``Just`` nodes (nor for any other datatype). Accordingly, the *kind* of an unboxed type is different from the kind of a boxed type. -The Haskell Report describes that ``*`` is the kind of ordinary datatypes, -such as ``Int``. Furthermore, type constructors can have kinds with arrows; -for example, ``Maybe`` has kind ``* -> *``. Unboxed types have a kind that -specifies their runtime representation. For example, the type ``Int#`` has -kind ``TYPE 'IntRep`` and ``Double#`` has kind ``TYPE 'DoubleRep``. These -kinds say that the runtime representation of an ``Int#`` is a machine integer, -and the runtime representation of a ``Double#`` is a machine double-precision -floating point. In contrast, the kind ``*`` is actually just a synonym -for ``TYPE 'LiftedRep``. More details of the ``TYPE`` mechanisms appear in -the `section on runtime representation polymorphism <#runtime-rep>`__. - -Given that ``Int#``'s kind is not ``*``, it then it follows that -``Maybe Int#`` is disallowed. Similarly, because type variables tend -to be of kind ``*`` (for example, in ``(.) :: (b -> c) -> (a -> b) -> a -> c``, -all the type variables have kind ``*``), polymorphism tends not to work -over primitive types. Stepping back, this makes some sense, because -a polymorphic function needs to manipulate the pointers to its data, -and most primitive types are unboxed. +The Haskell Report describes that ``*`` (spelled ``Type`` and imported from +``Data.Kind`` in the GHC dialect of Haskell) is the kind of ordinary datatypes, +such as ``Int``. Furthermore, type constructors can have kinds with arrows; for +example, ``Maybe`` has kind ``Type -> Type``. Unboxed types have a kind that +specifies their runtime representation. For example, the type ``Int#`` has kind +``TYPE 'IntRep`` and ``Double#`` has kind ``TYPE 'DoubleRep``. These kinds say +that the runtime representation of an ``Int#`` is a machine integer, and the +runtime representation of a ``Double#`` is a machine double-precision floating +point. In contrast, the kind ``Type`` is actually just a synonym for ``TYPE +'LiftedRep``. More details of the ``TYPE`` mechanisms appear in the `section +on runtime representation polymorphism <#runtime-rep>`__. + +Given that ``Int#``'s kind is not ``Type``, it then it follows that ``Maybe +Int#`` is disallowed. Similarly, because type variables tend to be of kind +``Type`` (for example, in ``(.) :: (b -> c) -> (a -> b) -> a -> c``, all the +type variables have kind ``Type``), polymorphism tends not to work over +primitive types. Stepping back, this makes some sense, because a polymorphic +function needs to manipulate the pointers to its data, and most primitive types +are unboxed. There are some restrictions on the use of primitive types: @@ -2310,12 +2311,12 @@ Data types with no constructors With the :extension:`EmptyDataDecls` extension, GHC lets you declare a data type with no constructors. For example: :: - data S -- S :: * - data T a -- T :: * -> * + data S -- S :: Type + data T a -- T :: Type -> Type -Syntactically, the declaration lacks the "= constrs" part. The type can -be parameterised over types of any kind, but if the kind is not ``*`` -then an explicit kind annotation must be used (see :ref:`kinding`). +Syntactically, the declaration lacks the "= constrs" part. The type can be +parameterised over types of any kind, but if the kind is not ``Type`` then an +explicit kind annotation must be used (see :ref:`kinding`). Such data types have only one value, namely bottom. Nevertheless, they can be useful when defining "phantom types". @@ -2944,16 +2945,16 @@ type declarations. in the "``data Set a where``" header have no scope. Indeed, one can write a kind signature instead: :: - data Set :: * -> * where ... + data Set :: Type -> Type where ... or even a mixture of the two: :: - data Bar a :: (* -> *) -> * where ... + data Bar a :: (Type -> Type) -> Type where ... The type variables (if given) may be explicitly kinded, so we could also write the header for ``Foo`` like this: :: - data Bar a (b :: * -> *) where ... + data Bar a (b :: Type -> Type) where ... - You can use strictness annotations, in the obvious places in the constructor type: :: @@ -4046,7 +4047,7 @@ Deriving ``Functor`` instances With :extension:`DeriveFunctor`, one can derive ``Functor`` instances for data types -of kind ``* -> *``. For example, this declaration:: +of kind ``Type -> Type``. For example, this declaration:: data Example a = Ex a Char (Example a) (Example Char) deriving Functor @@ -4239,7 +4240,7 @@ Deriving ``Foldable`` instances Allow automatic deriving of instances for the ``Foldable`` typeclass. With :extension:`DeriveFoldable`, one can derive ``Foldable`` instances for data types -of kind ``* -> *``. For example, this declaration:: +of kind ``Type -> Type``. For example, this declaration:: data Example a = Ex a Char (Example a) (Example Char) deriving Foldable @@ -4381,7 +4382,7 @@ Deriving ``Traversable`` instances Allow automatic deriving of instances for the ``Traversable`` typeclass. With :extension:`DeriveTraversable`, one can derive ``Traversable`` instances for data -types of kind ``* -> *``. For example, this declaration:: +types of kind ``Type -> Type``. For example, this declaration:: data Example a = Ex a Char (Example a) (Example Char) deriving (Functor, Foldable, Traversable) @@ -4729,7 +4730,7 @@ which really behave differently for the newtype and its representation. including: * :extension:`UnboxedTuples` - * :extension:`TypeInType` + * :extension:`PolyKinds` * :extension:`MultiParamTypeClasses` * :extension:`FlexibleContexts` @@ -6315,9 +6316,9 @@ original definition of ``Collects`` with a simple dependency: :: The dependency ``ce -> e`` here specifies that the type ``e`` of elements is uniquely determined by the type of the collection ``ce``. Note that both -parameters of Collects are of kind ``*``; there are no constructor classes -here. Note too that all of the instances of ``Collects`` that we gave -earlier can be used together with this new definition. +parameters of Collects are of kind ``Type``; there are no constructor classes +here. Note too that all of the instances of ``Collects`` that we gave earlier +can be used together with this new definition. What about the ambiguity problems that we encountered with the original definition? The empty function still has type ``Collects e ce => ce``, but @@ -7358,7 +7359,7 @@ example (Trac #10318) :: Fractional (Frac a), IntegralDomain (Frac a)) => IntegralDomain a where - type Frac a :: * + type Frac a :: Type Here the superclass cycle does terminate but it's not entirely straightforward to see that it does. @@ -7464,11 +7465,11 @@ Data family declarations Indexed data families are introduced by a signature, such as :: - data family GMap k :: * -> * + data family GMap k :: Type -> Type The special ``family`` distinguishes family from standard data declarations. The result kind annotation is optional and, as usual, -defaults to ``*`` if omitted. An example is :: +defaults to ``Type`` if omitted. An example is :: data family Array e @@ -7476,12 +7477,12 @@ Named arguments can also be given explicit kind signatures if needed. Just as with :ref:`GADT declarations <gadt>` named arguments are entirely optional, so that we can declare ``Array`` alternatively with :: - data family Array :: * -> * + data family Array :: Type -> Type Unlike with ordinary data definitions, the result kind of a data family -does not need to be ``*``: it can alternatively be a kind variable +does not need to be ``Type``: it can alternatively be a kind variable (with :extension:`PolyKinds`). Data instances' kinds must end in -``*``, however. +``Type``, however. .. _data-instance-declarations: @@ -7608,11 +7609,11 @@ Type family declarations Open indexed type families are introduced by a signature, such as :: - type family Elem c :: * + type family Elem c :: Type The special ``family`` distinguishes family from standard type declarations. The result kind annotation is optional and, as usual, -defaults to ``*`` if omitted. An example is :: +defaults to ``Type`` if omitted. An example is :: type family Elem c @@ -7625,18 +7626,19 @@ determine a family's arity, and hence in general, also insufficient to determine whether a type family application is well formed. As an example, consider the following declaration: :: - type family F a b :: * -> * -- F's arity is 2, - -- although its overall kind is * -> * -> * -> * + type family F a b :: Type -> Type + -- F's arity is 2, + -- although its overall kind is Type -> Type -> Type -> Type Given this declaration the following are examples of well-formed and malformed types: :: - F Char [Int] -- OK! Kind: * -> * - F Char [Int] Bool -- OK! Kind: * + F Char [Int] -- OK! Kind: Type -> Type + F Char [Int] Bool -- OK! Kind: Type F IO Bool -- WRONG: kind mismatch in the first argument F Bool -- WRONG: unsaturated application -The result kind annotation is optional and defaults to ``*`` (like +The result kind annotation is optional and defaults to ``Type`` (like argument kinds) if omitted. Polykinded type families can be declared using a parameter in the kind annotation: :: @@ -7720,7 +7722,7 @@ Type family examples Here are some examples of admissible and illegal type instances: :: - type family F a :: * + type family F a :: Type type instance F [Int] = Int -- OK! type instance F String = Char -- OK! type instance F (F a) = a -- WRONG: type parameter mentions a type family @@ -7735,7 +7737,7 @@ Here are some examples of admissible and illegal type instances: :: type instance H Char = Char -- WRONG: cannot have instances of closed family type family K a where -- OK! - type family G a b :: * -> * + type family G a b :: Type -> Type type instance G Int = (,) -- WRONG: must be two type parameters type instance G Int Char Float = Double -- WRONG: must be two type parameters @@ -7786,8 +7788,8 @@ like types. For example, the following is accepted: :: type instance J Int = Bool type instance J Int = Maybe -These instances are compatible because they differ in their implicit -kind parameter; the first uses ``*`` while the second uses ``* -> *``. +These instances are compatible because they differ in their implicit kind +parameter; the first uses ``Type`` while the second uses ``Type -> Type``. The definition for "compatible" uses a notion of "apart", whose definition in turn relies on type family reduction. This condition of @@ -7879,11 +7881,11 @@ When the name of a type argument of a data or type instance declaration doesn't matter, it can be replaced with an underscore (``_``). This is the same as writing a type variable with a unique name. :: - data family F a b :: * + data family F a b :: Type data instance F Int _ = Int -- Equivalent to data instance F Int b = Int - type family T a :: * + type family T a :: Type type instance T (a,_) = a -- Equivalent to type instance T (a,b) = a @@ -7910,11 +7912,11 @@ A data or type synonym family can be declared as part of a type class, thus: :: class GMapKey k where - data GMap k :: * -> * + data GMap k :: Type -> Type ... class Collects ce where - type Elem ce :: * + type Elem ce :: Type ... When doing so, we (optionally) may drop the "``family``" keyword. @@ -7926,7 +7928,7 @@ may be omitted and they may be in an order other than in the class head. Hence, the following contrived example is admissible: :: class C a b c where - type T c a x :: * + type T c a x :: Type Here ``c`` and ``a`` are class parameters, but the type is also indexed on a third parameter ``x``. @@ -7953,7 +7955,7 @@ the rule that the type indexes corresponding to class parameters must have precisely the same as type given in the instance head. For example: :: class Collects ce where - type Elem ce :: * + type Elem ce :: Type instance Eq (Elem [e]) => Collects [e] where -- Choose one of the following alternatives: @@ -7974,17 +7976,17 @@ Note the following points: to mention kind variables that are implicitly bound. For example, these are legitimate: :: - data family Nat :: k -> k -> * + data family Nat :: k -> k -> Type -- k is implicitly bound by an invisible kind pattern - newtype instance Nat :: (k -> *) -> (k -> *) -> * where + newtype instance Nat :: (k -> Type) -> (k -> Type) -> Type where Nat :: (forall xx. f xx -> g xx) -> Nat f g class Funct f where - type Codomain f :: * + type Codomain f :: Type instance Funct ('KProxy :: KProxy o) where -- o is implicitly bound by the kind signature -- of the LHS type pattern ('KProxy) - type Codomain 'KProxy = NatTr (Proxy :: o -> *) + type Codomain 'KProxy = NatTr (Proxy :: o -> Type) - The instance for an associated type can be omitted in class instances. In that case, unless there is a default instance (see @@ -8005,7 +8007,7 @@ Note the following points: parameter is ``[v]``, and one for which it is ``Int``. Since you cannot give any *subsequent* instances for ``(GMap Flob ...)``, this facility is most useful when the free indexed parameter is of a kind - with a finite number of alternatives (unlike ``*``). + with a finite number of alternatives (unlike ``Type``). .. _assoc-decl-defs: @@ -8050,8 +8052,8 @@ Here are some examples: :: - class C (a :: *) where - type F1 a :: * + class C (a :: Type) where + type F1 a :: Type type instance F1 a = [a] -- OK type instance F1 a = a->a -- BAD; only one default instance is allowed @@ -8186,7 +8188,7 @@ Recall our running ``GMapKey`` class example: :: class GMapKey k where - data GMap k :: * -> * + data GMap k :: Type -> Type insert :: GMap k v -> k -> v -> GMap k v lookup :: GMap k v -> k -> Maybe v empty :: GMap k v @@ -8482,7 +8484,7 @@ Motivation Standard Haskell has a rich type language. Types classify terms and serve to avoid many common programming mistakes. The kind language, however, is relatively simple, distinguishing only regular types (kind -``*``) and type constructors (e.g. kind ``* -> * -> *``). +``Type``) and type constructors (e.g. kind ``Type -> Type -> Type``). In particular when using advanced type system features, such as type families (:ref:`type-families`) or GADTs (:ref:`gadt`), this simple kind system is insufficient, and fails to @@ -8492,11 +8494,11 @@ numbers, and length-indexed vectors: :: data Ze data Su n - data Vec :: * -> * -> * where + data Vec :: Type -> Type -> Type where Nil :: Vec a Ze Cons :: a -> Vec a n -> Vec a (Su n) -The kind of ``Vec`` is ``* -> * -> *``. This means that, e.g., +The kind of ``Vec`` is ``Type -> Type -> Type``. This means that, e.g., ``Vec Int Char`` is a well-kinded type, even though this is not what we intend when defining length-indexed vectors. @@ -8504,7 +8506,7 @@ With :extension:`DataKinds`, the example above can then be rewritten to: :: data Nat = Ze | Su Nat - data Vec :: * -> Nat -> * where + data Vec :: Type -> Nat -> Type where Nil :: Vec a 'Ze Cons :: a -> Vec a n -> Vec a ('Su n) @@ -8529,48 +8531,27 @@ following types :: give rise to the following kinds and type constructors (where promoted constructors are prefixed by a tick ``'``): :: - Nat :: * + Nat :: Type 'Zero :: Nat 'Succ :: Nat -> Nat - List :: * -> * + List :: Type -> Type 'Nil :: forall k. List k 'Cons :: forall k. k -> List k -> List k - Pair :: * -> * -> * + Pair :: Type -> Type -> Type 'Pair :: forall k1 k2. k1 -> k2 -> Pair k1 k2 - Sum :: * -> * -> * + Sum :: Type -> Type -> Type 'L :: k1 -> Sum k1 k2 'R :: k2 -> Sum k1 k2 -The following restrictions apply to promotion: - -- We promote ``data`` types and ``newtypes``; type synonyms and - type/data families are not promoted (:ref:`type-families`). - -- We only promote types whose kinds are of the form - ``* -> ... -> * -> *``. In particular, we do not promote - higher-kinded datatypes such as ``data Fix f = In (f (Fix f))``, or - datatypes whose kinds involve promoted types such as - ``Vec :: * -> Nat -> *``. - -- We do not promote data constructors that are kind polymorphic, - involve constraints, mention type or data families, or involve types - that are not promotable. - -The flag :extension:`TypeInType` (which implies :extension:`DataKinds`) -relaxes some of these restrictions, allowing: - -- Promotion of type synonyms and type families, but not data families. - GHC's type theory just isn't up to the task of promoting data families, - which requires full dependent types. - -- All datatypes, even those with rich kinds, get promoted. For example: :: +.. note:: + Data family instances cannot be promoted at the moment: GHC’s type theory + just isn’t up to the task of promoting data families, which requires full + dependent types. - data Proxy a = Proxy - data App f a = MkApp (f a) -- App :: forall k. (k -> *) -> k -> * - x = Proxy :: Proxy ('MkApp ('Just 'True)) + See also :ghc-ticket:`15245`. .. _promotion-syntax: @@ -8612,11 +8593,11 @@ With :extension:`DataKinds`, Haskell's list and tuple types are natively promoted to kinds, and enjoy the same convenient syntax at the type level, albeit prefixed with a quote: :: - data HList :: [*] -> * where + data HList :: [Type] -> Type where HNil :: HList '[] HCons :: a -> HList t -> HList (a ': t) - data Tuple :: (*,*) -> * where + data Tuple :: (Type,Type) -> Type where Tuple :: a -> b -> Tuple '(a,b) foo0 :: HList '[] @@ -8647,7 +8628,7 @@ Promoting existential data constructors Note that we do promote existential data constructors that are otherwise suitable. For example, consider the following: :: - data Ex :: * where + data Ex :: Type where MkEx :: forall a. a -> Ex Both the type ``Ex`` and the data constructor ``MkEx`` get promoted, @@ -8666,7 +8647,7 @@ The return kind ``k`` is an implicit parameter to ``UnEx``. The elaborated definitions are as follows (where implicit parameters are denoted by braces): :: - type family UnEx {k :: *} (ex :: Ex) :: k + type family UnEx {k :: Type} (ex :: Ex) :: k type instance UnEx {k} (MkEx @k x) = x Thus, the instance triggers only when the implicit parameter to ``UnEx`` @@ -8679,22 +8660,18 @@ See also :ghc-ticket:`7347`. .. _type-in-type: .. _kind-polymorphism: -Kind polymorphism and Type-in-Type +Kind polymorphism ================================== .. extension:: TypeInType - :shortdesc: Allow kinds to be used as types, - including explicit kind variable quantification, higher-rank - kinds, kind synonyms, and kind families. - Implies :extension:`DataKinds`, :extension:`KindSignatures`, - and :extension:`PolyKinds`. + :shortdesc: Deprecated. Enable kind polymorphism and datatype promotion. - :implies: :extension:`PolyKinds`, :extension:`DataKinds`, :extension:`KindSignatures` + :implies: :extension:`PolyKinds`, :extension:`DataKinds`, :extension:`KindSignatures`, + :extension:`NoStarIsType` :since: 8.0.1 - Allow kinds to be as intricate as types, allowing explicit quantification - over kind variables, higher-rank kinds, and the use of type synonyms and - families in kinds, among other features. + In the past this extension used to enable advanced type-level programming + techniques. Now it's a shorthand for a couple of other extensions. .. extension:: PolyKinds :shortdesc: Enable kind polymorphism. @@ -8711,31 +8688,6 @@ although it is a conservative extension beyond standard Haskell. The extensions above simply enable syntax and tweak the inference algorithm to allow users to take advantage of the extra expressiveness of GHC's kind system. -The difference between :extension:`TypeInType` and :extension:`PolyKinds` ---------------------------------------------------------------------------- - -It is natural to consider :extension:`TypeInType` as an extension of -:extension:`PolyKinds`. The latter simply enables fewer features of GHC's -rich kind system than does the former. The need for two separate extensions -stems from their history: :extension:`PolyKinds` was introduced for GHC 7.4, -when it was experimental and temperamental. The wrinkles were smoothed out for -GHC 7.6. :extension:`TypeInType` was introduced for GHC 8.0, and is currently -experimental and temperamental, with the wrinkles to be smoothed out in due -course. The intent of having the two extensions is that users can rely on -:extension:`PolyKinds` to work properly while being duly sceptical of -:extension:`TypeInType`. In particular, we recommend enabling -:ghc-flag:`-dcore-lint` whenever using :extension:`TypeInType`; that extension -turns on a set of internal checks within GHC that will discover bugs in the -implementation of :extension:`TypeInType`. Please report bugs at `our bug -tracker <https://ghc.haskell.org/trac/ghc/wiki/ReportABug>`__. - -Although we have tried to allow the new behavior only when -:extension:`TypeInType` is enabled, some particularly thorny cases may have -slipped through. It is thus possible that some construct is available in GHC -8.0 with :extension:`PolyKinds` that was not possible in GHC 7.x. If you spot -such a case, you are welcome to submit that as a bug as well. We flag -newly-available capabilities below. - Overview of kind polymorphism ----------------------------- @@ -8743,22 +8695,22 @@ Consider inferring the kind for :: data App f a = MkApp (f a) -In Haskell 98, the inferred kind for ``App`` is ``(* -> *) -> * -> *``. -But this is overly specific, because another suitable Haskell 98 kind for -``App`` is ``((* -> *) -> *) -> (* -> *) -> *``, where the kind assigned -to ``a`` is ``* -> *``. Indeed, without kind signatures -(:extension:`KindSignatures`), it is necessary to use a dummy constructor -to get a Haskell compiler to infer the second kind. With kind polymorphism -(:extension:`PolyKinds`), GHC infers the kind ``forall k. (k -> *) -> k -> *`` -for ``App``, which is its most general kind. +In Haskell 98, the inferred kind for ``App`` is ``(Type -> Type) -> Type -> +Type``. But this is overly specific, because another suitable Haskell 98 kind +for ``App`` is ``((Type -> Type) -> Type) -> (Type -> Type) -> Type``, where the +kind assigned to ``a`` is ``Type -> Type``. Indeed, without kind signatures +(:extension:`KindSignatures`), it is necessary to use a dummy constructor to get +a Haskell compiler to infer the second kind. With kind polymorphism +(:extension:`PolyKinds`), GHC infers the kind ``forall k. (k -> Type) -> k -> +Type`` for ``App``, which is its most general kind. Thus, the chief benefit of kind polymorphism is that we can now infer these most general kinds and use ``App`` at a variety of kinds: :: - App Maybe Int -- `k` is instantiated to * + App Maybe Int -- `k` is instantiated to Type - data T a = MkT (a Int) -- `a` is inferred to have kind (* -> *) - App T Maybe -- `k` is instantiated to (* -> *) + data T a = MkT (a Int) -- `a` is inferred to have kind (Type -> Type) + App T Maybe -- `k` is instantiated to (Type -> Type) Overview of Type-in-Type ------------------------ @@ -8773,16 +8725,15 @@ between types and kinds is a hallmark of dependently typed languages. Full dependently typed languages also remove the difference between expressions and types, but doing that in GHC is a story for another day. -One simplification allowed by combining types and kinds is that the type -of ``*`` is just ``*``. It is true that the ``* :: *`` axiom can lead to -non-termination, but this is not a problem in GHC, as we already have other -means of non-terminating programs in both types and expressions. This -decision (among many, many others) *does* mean that despite the expressiveness -of GHC's type system, a "proof" you write in Haskell is not an irrefutable -mathematical proof. GHC promises only partial correctness, that if your -programs compile and run to completion, their results indeed have the types -assigned. It makes no claim about programs that do not finish in a finite -amount of time. +One simplification allowed by combining types and kinds is that the type of +``Type`` is just ``Type``. It is true that the ``Type :: Type`` axiom can lead +to non-termination, but this is not a problem in GHC, as we already have other +means of non-terminating programs in both types and expressions. This decision +(among many, many others) *does* mean that despite the expressiveness of GHC's +type system, a "proof" you write in Haskell is not an irrefutable mathematical +proof. GHC promises only partial correctness, that if your programs compile and +run to completion, their results indeed have the types assigned. It makes no +claim about programs that do not finish in a finite amount of time. To learn more about this decision and the design of GHC under the hood please see the `paper <http://www.seas.upenn.edu/~sweirich/papers/fckinds.pdf>`__ @@ -8802,13 +8753,13 @@ inference. But that is not always the case. Consider :: Type family declarations have no right-hand side, but GHC must still infer a kind for ``F``. Since there are no constraints, it could infer ``F :: forall k1 k2. k1 -> k2``, but that seems *too* polymorphic. So -GHC defaults those entirely-unconstrained kind variables to ``*`` and we -get ``F :: * -> *``. You can still declare ``F`` to be kind-polymorphic +GHC defaults those entirely-unconstrained kind variables to ``Type`` and we +get ``F :: Type -> Type``. You can still declare ``F`` to be kind-polymorphic using kind signatures: :: - type family F1 a -- F1 :: * -> * - type family F2 (a :: k) -- F2 :: forall k. k -> * - type family F3 a :: k -- F3 :: forall k. * -> k + type family F1 a -- F1 :: Type -> Type + type family F2 (a :: k) -- F2 :: forall k. k -> Type + type family F3 a :: k -- F3 :: forall k. Type -> k type family F4 (a :: k1) :: k2 -- F4 :: forall k1 k2. k1 -> k2 The general principle is this: @@ -8820,7 +8771,7 @@ The general principle is this: class method signatures. - *When there is no right hand side, GHC defaults argument and result - kinds to ``*``, except when directed otherwise by a kind signature*. + kinds to ``Type``, except when directed otherwise by a kind signature*. Examples: data and open type family declarations. This rule has occasionally-surprising consequences (see @@ -8830,10 +8781,10 @@ This rule has occasionally-surprising consequences (see -- so C :: forall k. k -> Constraint data D1 a -- No right hand side for these two family type F1 a -- declarations, but the class forces (a :: k) - -- so D1, F1 :: forall k. k -> * + -- so D1, F1 :: forall k. k -> Type - data D2 a -- No right-hand side so D2 :: * -> * - type F2 a -- No right-hand side so F2 :: * -> * + data D2 a -- No right-hand side so D2 :: Type -> Type + type F2 a -- No right-hand side so F2 :: Type -> Type The kind-polymorphism from the class declaration makes ``D1`` kind-polymorphic, but not so ``D2``; and similarly ``F1``, ``F1``. @@ -8851,21 +8802,21 @@ Just as in type inference, kind inference for recursive types can only use *monomorphic* recursion. Consider this (contrived) example: :: data T m a = MkT (m a) (T Maybe (m a)) - -- GHC infers kind T :: (* -> *) -> * -> * + -- GHC infers kind T :: (Type -> Type) -> Type -> Type The recursive use of ``T`` forced the second argument to have kind -``*``. However, just as in type inference, you can achieve polymorphic +``Type``. However, just as in type inference, you can achieve polymorphic recursion by giving a *complete user-supplied kind signature* (or CUSK) for ``T``. A CUSK is present when all argument kinds and the result kind are known, without any need for inference. For example: :: - data T (m :: k -> *) :: k -> * where + data T (m :: k -> Type) :: k -> Type where MkT :: m a -> T Maybe (m a) -> T m a The complete user-supplied kind signature specifies the polymorphic kind for ``T``, and this signature is used for all the calls to ``T`` including the recursive ones. In particular, the recursive use of ``T`` -is at kind ``*``. +is at kind ``Type``. What exactly is considered to be a "complete user-supplied kind signature" for a type constructor? These are the forms: @@ -8876,35 +8827,30 @@ signature" for a type constructor? These are the forms: annotation does not affect whether or not the declaration has a complete signature. :: - data T1 :: (k -> *) -> k -> * where ... - -- Yes; T1 :: forall k. (k->*) -> k -> * + data T1 :: (k -> Type) -> k -> Type where ... + -- Yes; T1 :: forall k. (k->Type) -> k -> Type - data T2 (a :: k -> *) :: k -> * where ... - -- Yes; T2 :: forall k. (k->*) -> k -> * + data T2 (a :: k -> Type) :: k -> Type where ... + -- Yes; T2 :: forall k. (k->Type) -> k -> Type - data T3 (a :: k -> *) (b :: k) :: * where ... - -- Yes; T3 :: forall k. (k->*) -> k -> * + data T3 (a :: k -> Type) (b :: k) :: Type where ... + -- Yes; T3 :: forall k. (k->Type) -> k -> Type - data T4 (a :: k -> *) (b :: k) where ... - -- Yes; T4 :: forall k. (k->*) -> k -> * + data T4 (a :: k -> Type) (b :: k) where ... + -- Yes; T4 :: forall k. (k->Type) -> k -> Type - data T5 a (b :: k) :: * where ... + data T5 a (b :: k) :: Type where ... -- No; kind is inferred data T6 a b where ... -- No; kind is inferred -- For a datatype with a top-level ``::`` when :extension:`TypeInType` - is in effect: all kind variables introduced after the ``::`` must - be explicitly quantified. :: - - -- -XTypeInType is on - data T1 :: k -> * -- No CUSK: `k` is not explicitly quantified - data T2 :: forall k. k -> * -- CUSK: `k` is bound explicitly - data T3 :: forall (k :: *). k -> * -- still a CUSK +- For a datatype with a top-level ``::``: all kind variables introduced after + the ``::`` must be explicitly quantified. :: - Note that the first example would indeed have a CUSK without - :extension:`TypeInType`. + data T1 :: k -> Type -- No CUSK: `k` is not explicitly quantified + data T2 :: forall k. k -> Type -- CUSK: `k` is bound explicitly + data T3 :: forall (k :: Type). k -> Type -- still a CUSK - For a class, every type variable must be annotated with a kind. @@ -8920,13 +8866,12 @@ signature" for a type constructor? These are the forms: signature -- no inference can be done before detecting the signature. - An un-associated open type or data family declaration *always* has a CUSK; - un-annotated type variables default to - kind ``*``: :: + un-annotated type variables default to kind ``Type``: :: - data family D1 a -- D1 :: * -> * - data family D2 (a :: k) -- D2 :: forall k. k -> * - data family D3 (a :: k) :: * -- D3 :: forall k. k -> * - type family S1 a :: k -> * -- S1 :: forall k. * -> k -> * + data family D1 a -- D1 :: Type -> Type + data family D2 (a :: k) -- D2 :: forall k. k -> Type + data family D3 (a :: k) :: Type -- D3 :: forall k. k -> Type + type family S1 a :: k -> Type -- S1 :: forall k. Type -> k -> Type - An associated type or data family declaration has a CUSK precisely if its enclosing class has a CUSK. :: @@ -8941,11 +8886,11 @@ signature" for a type constructor? These are the forms: variables are annotated and a return kind (with a top-level ``::``) is supplied. -With :extension:`TypeInType` enabled, it is possible to write a datatype -that syntactically has a CUSK (according to the rules above) -but actually requires some inference. As a very contrived example, consider :: +It is possible to write a datatype that syntactically has a CUSK (according to +the rules above) but actually requires some inference. As a very contrived +example, consider :: - data Proxy a -- Proxy :: forall k. k -> * + data Proxy a -- Proxy :: forall k. k -> Type data X (a :: Proxy k) According to the rules above ``X`` has a CUSK. Yet, what is the kind of ``k``? @@ -9008,9 +8953,9 @@ for it: :: In the class declaration, nothing constrains the kind of the type ``a``, so it becomes a poly-kinded type variable ``(a :: k)``. Yet, in the instance declaration, the right-hand side of the associated type -instance ``b -> b`` says that ``b`` must be of kind ``*``. GHC could +instance ``b -> b`` says that ``b`` must be of kind ``Type``. GHC could theoretically propagate this information back into the instance head, -and make that instance declaration apply only to type of kind ``*``, as +and make that instance declaration apply only to type of kind ``Type``, as opposed to types of any kind. However, GHC does *not* do this. In short: GHC does *not* propagate kind information from the members of @@ -9031,23 +8976,23 @@ type when figuring out how to generalise the type's kind. For example, consider these definitions (with :extension:`ScopedTypeVariables`): :: - data Proxy a -- Proxy :: forall k. k -> * + data Proxy a -- Proxy :: forall k. k -> Type p :: forall a. Proxy a - p = Proxy :: Proxy (a :: *) + p = Proxy :: Proxy (a :: Type) GHC reports an error, saying that the kind of ``a`` should be a kind variable -``k``, not ``*``. This is because, by looking at the type signature +``k``, not ``Type``. This is because, by looking at the type signature ``forall a. Proxy a``, GHC assumes ``a``'s kind should be generalised, not -restricted to be ``*``. The function definition is then rejected for being +restricted to be ``Type``. The function definition is then rejected for being more specific than its type signature. Explicit kind quantification ---------------------------- -Enabled by :extension:`TypeInType`, GHC now supports explicit kind quantification, +Enabled by :extension:`PolyKinds`, GHC supports explicit kind quantification, as in these examples: :: - data Proxy :: forall k. k -> * + data Proxy :: forall k. k -> Type f :: (forall k (a :: k). Proxy a -> ()) -> Int Note that the second example has a ``forall`` that binds both a kind ``k`` and @@ -9078,8 +9023,8 @@ Consider the type :: This datatype ``G`` is GADT-like in both its kind and its type. Suppose you have ``g :: G a``, where ``a :: k``. Then pattern matching to discover that -``g`` is in fact ``GMaybe`` tells you both that ``k ~ (* -> *)`` and -``a ~ Maybe``. The definition for ``G`` requires that :extension:`TypeInType` +``g`` is in fact ``GMaybe`` tells you both that ``k ~ (Type -> Type)`` and +``a ~ Maybe``. The definition for ``G`` requires that :extension:`PolyKinds` be in effect, but pattern-matching on ``G`` requires no extension beyond :extension:`GADTs`. That this works is actually a straightforward extension of regular GADTs and a consequence of the fact that kinds and types are the @@ -9151,7 +9096,7 @@ distinction). GHC does not consider ``forall k. k -> Type`` and Constraints in kinds -------------------- -As kinds and types are the same, kinds can now (with :extension:`TypeInType`) +As kinds and types are the same, kinds can (with :extension:`PolyKinds`) contain type constraints. Only equality constraints are currently supported, however. We expect this to extend to other constraints in the future. @@ -9162,7 +9107,7 @@ Here is an example of a constrained kind: :: IsTypeLit Symbol = 'True IsTypeLit a = 'False - data T :: forall a. (IsTypeLit a ~ 'True) => a -> * where + data T :: forall a. (IsTypeLit a ~ 'True) => a -> Type where MkNat :: T 42 MkSymbol :: T "Don't panic!" @@ -9171,50 +9116,23 @@ we get an error that the equality constraint is not satisfied; ``Int`` is not a type literal. Note that explicitly quantifying with ``forall a`` is not necessary here. -The kind ``*`` --------------- - -The kind ``*`` classifies ordinary types. Without :extension:`TypeInType`, -this identifier is always in scope when writing a kind. However, with -:extension:`TypeInType`, a user may wish to use ``*`` in a type or a -type operator ``*`` in a kind. To make this all more manageable, ``*`` -becomes an (almost) ordinary name with :extension:`TypeInType` enabled. -So as not to cause naming collisions, it is not imported by default; -you must ``import Data.Kind`` to get ``*`` (but only with :extension:`TypeInType` -enabled). - -The only way ``*`` is unordinary is in its parsing. In order to be backward -compatible, ``*`` is parsed as if it were an alphanumeric identifier; note -that we do not write ``Int :: (*)`` but just plain ``Int :: *``. Due to the -bizarreness with which ``*`` is parsed--and the fact that it is the only such -operator in GHC--there are some corner cases that are -not handled. We are aware of three: - -- In a Haskell-98-style data constructor, you must put parentheses around - ``*``, like this: :: - - data Universe = Ty (*) | Num Int | ... - -- In an import/export list, you must put parentheses around ``*``, like this: :: - - import Data.Kind ( type (*) ) - - Note that the keyword ``type`` there is just to disambiguate the import - from a term-level ``(*)``. (:ref:`explicit-namespaces`) +The kind ``Type`` +----------------- -- In an instance declaration head (the part after the word ``instance``), you - must parenthesize ``*``. This applies to all manners of instances, including - the left-hand sides of individual equations of a closed type family. +.. extension:: StarIsType + :shortdesc: Desugar ``*`` to ``Data.Kind.Type``. -The ``Data.Kind`` module also exports ``Type`` as a synonym for ``*``. -Now that type synonyms work in kinds, it is conceivable that we will deprecate -``*`` when there is a good migration story for everyone to use ``Type``. -If you like neither of these names, feel free to write your own synonym: :: + :since: 8.6.1 - type Set = * -- silly Agda programmers... + Treat the unqualified uses of the ``*`` type operator as nullary and desugar + to ``Data.Kind.Type``. Disabled by :extension:`TypeOperators` and + :extension:`TypeInType`. -All the affordances for ``*`` also apply to ``★``, the Unicode variant -of ``*``. +The kind ``Type`` (imported from ``Data.Kind``) classifies ordinary types. With +:extension:`StarIsType` (currently enabled by default), ``*`` is desugared to +``Type``, but using this legacy syntax is not recommended due to conflicts with +:extension:`TypeOperators`. This also applies to ``★``, the Unicode variant of +``*``. Inferring dependency in datatype declarations --------------------------------------------- @@ -9274,16 +9192,17 @@ the program. Kind defaulting without :extension:`PolyKinds` ----------------------------------------------- -Without :extension:`PolyKinds` or :extension:`TypeInType` enabled, GHC -refuses to generalise over kind variables. It thus defaults kind variables -to ``*`` when possible; when this is not possible, an error is issued. +Without :extension:`PolyKinds`, GHC refuses to generalise over kind variables. +It thus defaults kind variables to ``Type`` when possible; when this is not +possible, an error is issued. Here is an example of this in action: :: - {-# LANGUAGE TypeInType #-} - data Proxy a = P -- inferred kind: Proxy :: k -> * + {-# LANGUAGE PolyKinds #-} + import Data.Kind (Type) + data Proxy a = P -- inferred kind: Proxy :: k -> Type data Compose f g x = MkCompose (f (g x)) - -- inferred kind: Compose :: (b -> *) -> (a -> b) -> a -> * + -- inferred kind: Compose :: (b -> Type) -> (a -> b) -> a -> Type -- separate module having imported the first {-# LANGUAGE NoPolyKinds, DataKinds #-} @@ -9292,13 +9211,13 @@ Here is an example of this in action: :: In the last line, we use the promoted constructor ``'MkCompose``, which has kind :: - forall (a :: *) (b :: *) (f :: b -> *) (g :: a -> b) (x :: a). + forall (a :: Type) (b :: Type) (f :: b -> Type) (g :: a -> b) (x :: a). f (g x) -> Compose f g x Now we must infer a type for ``z``. To do so without generalising over kind -variables, we must default the kind variables of ``'MkCompose``. We can -easily default ``a`` and ``b`` to ``*``, but ``f`` and ``g`` would be ill-kinded -if defaulted. The definition for ``z`` is thus an error. +variables, we must default the kind variables of ``'MkCompose``. We can easily +default ``a`` and ``b`` to ``Type``, but ``f`` and ``g`` would be ill-kinded if +defaulted. The definition for ``z`` is thus an error. Pretty-printing in the presence of kind polymorphism ---------------------------------------------------- @@ -9328,7 +9247,7 @@ polymorphism. Here are the key definitions, all available from ``GHC.Exts``: :: - TYPE :: RuntimeRep -> * -- highly magical, built into GHC + TYPE :: RuntimeRep -> Type -- highly magical, built into GHC data RuntimeRep = LiftedRep -- for things like `Int` | UnliftedRep -- for things like `Array#` @@ -9337,7 +9256,7 @@ Here are the key definitions, all available from ``GHC.Exts``: :: | SumRep [RuntimeRep] -- unboxed sums, indexed by the representations of the disjuncts | ... - type * = TYPE LiftedRep -- * is just an ordinary type synonym + type Type = TYPE LiftedRep -- Type is just an ordinary type synonym The idea is that we have a new fundamental type constant ``TYPE``, which is parameterised by a ``RuntimeRep``. We thus get ``Int# :: TYPE 'IntRep`` @@ -9375,7 +9294,7 @@ representation-polymorphic type. However, not all is lost. We can still do this: :: - ($) :: forall r (a :: *) (b :: TYPE r). + ($) :: forall r (a :: Type) (b :: TYPE r). (a -> b) -> a -> b f $ x = f x @@ -9421,7 +9340,8 @@ Most GHC users will not need to worry about levity polymorphism or unboxed types. For these users, seeing the levity polymorphism in the type of ``$`` is unhelpful. And thus, by default, it is suppressed, by supposing all type variables of type ``RuntimeRep`` to be ``'LiftedRep`` -when printing, and printing ``TYPE 'LiftedRep`` as ``*``. +when printing, and printing ``TYPE 'LiftedRep`` as ``Type`` (or ``*`` when +:extension:`StarIsType` is on). Should you wish to see levity polymorphism in your types, enable the flag :ghc-flag:`-fprint-explicit-runtime-reps`. @@ -9665,7 +9585,7 @@ The following things have kind ``Constraint``: - Anything whose form is not yet known, but the user has declared to have kind ``Constraint`` (for which they need to import it from ``GHC.Exts``). So for example - ``type Foo (f :: * -> Constraint) = forall b. f b => b -> b`` + ``type Foo (f :: Type -> Constraint) = forall b. f b => b -> b`` is allowed, as well as examples involving type families: :: type family Typ a b :: Constraint @@ -10195,29 +10115,27 @@ This extension enables kind signatures in the following places: - ``data`` declarations: :: - data Set (cxt :: * -> *) a = Set [a] + data Set (cxt :: Type -> Type) a = Set [a] - ``type`` declarations: :: - type T (f :: * -> *) = f Int + type T (f :: Type -> Type) = f Int - ``class`` declarations: :: - class (Eq a) => C (f :: * -> *) a where ... + class (Eq a) => C (f :: Type -> Type) a where ... - ``forall``\'s in type signatures: :: - f :: forall (cxt :: * -> *). Set cxt Int + f :: forall (cxt :: Type -> Type). Set cxt Int -The parentheses are required. Some of the spaces are required too, to -separate the lexemes. If you write ``(f::*->*)`` you will get a parse -error, because ``::*->*`` is a single lexeme in Haskell. +The parentheses are required. As part of the same extension, you can put kind annotations in types as well. Thus: :: - f :: (Int :: *) -> Int - g :: forall a. a -> (a :: *) + f :: (Int :: Type) -> Int + g :: forall a. a -> (a :: Type) The syntax is @@ -15611,7 +15529,7 @@ Haskell datatypes: :: -- | Unit: used for constructors without arguments data U1 p = U1 - -- | Constants, additional parameters and recursion of kind * + -- | Constants, additional parameters and recursion of kind Type newtype K1 i c p = K1 { unK1 :: c } -- | Meta-information (constructor names, etc.) @@ -15630,22 +15548,22 @@ datatypes and their internal representation as a sum-of-products: :: class Generic a where -- Encode the representation of a user datatype - type Rep a :: * -> * + type Rep a :: Type -> Type -- Convert from the datatype to its representation from :: a -> (Rep a) x -- Convert from the representation to the datatype to :: (Rep a) x -> a - class Generic1 (f :: k -> *) where - type Rep1 f :: k -> * + class Generic1 (f :: k -> Type) where + type Rep1 f :: k -> Type from1 :: f a -> Rep1 f a to1 :: Rep1 f a -> f a ``Generic1`` is used for functions that can only be defined over type containers, such as ``map``. Note that ``Generic1`` ranges over types of kind -``* -> *`` by default, but if the :extension:`PolyKinds` extension is enabled, -then it can range of types of kind ``k -> *``, for any kind ``k``. +``Type -> Type`` by default, but if the :extension:`PolyKinds` extension is +enabled, then it can range of types of kind ``k -> Type``, for any kind ``k``. .. extension:: DeriveGeneric :shortdesc: Enable deriving for the Generic class. diff --git a/libraries/base/Data/Data.hs b/libraries/base/Data/Data.hs index 6d214907e4..8154433044 100644 --- a/libraries/base/Data/Data.hs +++ b/libraries/base/Data/Data.hs @@ -4,12 +4,12 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} ----------------------------------------------------------------------------- @@ -1310,7 +1310,7 @@ deriving instance (Typeable f, Typeable g, Data p, Data (f p), Data (g p)) => Data ((f :+: g) p) -- | @since 4.9.0.0 -deriving instance (Typeable (f :: * -> *), Typeable (g :: * -> *), +deriving instance (Typeable (f :: Type -> Type), Typeable (g :: Type -> Type), Data p, Data (f (g p))) => Data ((f :.: g) p) diff --git a/libraries/base/Data/Kind.hs b/libraries/base/Data/Kind.hs index 348301347c..9ee7b7ab07 100644 --- a/libraries/base/Data/Kind.hs +++ b/libraries/base/Data/Kind.hs @@ -14,6 +14,6 @@ -- @since 4.9.0.0 ----------------------------------------------------------------------------- -module Data.Kind ( Type, Constraint, type (*), type (★) ) where +module Data.Kind ( Type, Constraint ) where import GHC.Types diff --git a/libraries/base/Data/Proxy.hs b/libraries/base/Data/Proxy.hs index cdbb0d4956..557cc1e4dd 100644 --- a/libraries/base/Data/Proxy.hs +++ b/libraries/base/Data/Proxy.hs @@ -59,7 +59,7 @@ data Proxy t = Proxy deriving ( Bounded -- ^ @since 4.7.0.0 -- | A concrete, promotable proxy type, for use at the kind level -- There are no instances for this because it is intended at the kind level only -data KProxy (t :: *) = KProxy +data KProxy (t :: Type) = KProxy -- It's common to use (undefined :: Proxy t) and (Proxy :: Proxy t) -- interchangeably, so all of these instances are hand-written to be diff --git a/libraries/base/Data/Type/Equality.hs b/libraries/base/Data/Type/Equality.hs index 8591499197..50b96c08c1 100644 --- a/libraries/base/Data/Type/Equality.hs +++ b/libraries/base/Data/Type/Equality.hs @@ -5,13 +5,13 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ExplicitNamespaces #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/Data/Typeable.hs b/libraries/base/Data/Typeable.hs index 61b70cfd2e..c9a8711d79 100644 --- a/libraries/base/Data/Typeable.hs +++ b/libraries/base/Data/Typeable.hs @@ -198,28 +198,30 @@ rnfTypeRep = I.rnfSomeTypeRep -- Keeping backwards-compatibility -typeOf1 :: forall t (a :: *). Typeable t => t a -> TypeRep +typeOf1 :: forall t (a :: Type). Typeable t => t a -> TypeRep typeOf1 _ = I.someTypeRep (Proxy :: Proxy t) -typeOf2 :: forall t (a :: *) (b :: *). Typeable t => t a b -> TypeRep +typeOf2 :: forall t (a :: Type) (b :: Type). Typeable t => t a b -> TypeRep typeOf2 _ = I.someTypeRep (Proxy :: Proxy t) -typeOf3 :: forall t (a :: *) (b :: *) (c :: *). Typeable t - => t a b c -> TypeRep +typeOf3 :: forall t (a :: Type) (b :: Type) (c :: Type). + Typeable t => t a b c -> TypeRep typeOf3 _ = I.someTypeRep (Proxy :: Proxy t) -typeOf4 :: forall t (a :: *) (b :: *) (c :: *) (d :: *). Typeable t - => t a b c d -> TypeRep +typeOf4 :: forall t (a :: Type) (b :: Type) (c :: Type) (d :: Type). + Typeable t => t a b c d -> TypeRep typeOf4 _ = I.someTypeRep (Proxy :: Proxy t) -typeOf5 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *). Typeable t - => t a b c d e -> TypeRep +typeOf5 :: forall t (a :: Type) (b :: Type) (c :: Type) (d :: Type) (e :: Type). + Typeable t => t a b c d e -> TypeRep typeOf5 _ = I.someTypeRep (Proxy :: Proxy t) -typeOf6 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *) (f :: *). - Typeable t => t a b c d e f -> TypeRep +typeOf6 :: forall t (a :: Type) (b :: Type) (c :: Type) + (d :: Type) (e :: Type) (f :: Type). + Typeable t => t a b c d e f -> TypeRep typeOf6 _ = I.someTypeRep (Proxy :: Proxy t) -typeOf7 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *) (f :: *) - (g :: *). Typeable t => t a b c d e f g -> TypeRep +typeOf7 :: forall t (a :: Type) (b :: Type) (c :: Type) + (d :: Type) (e :: Type) (f :: Type) (g :: Type). + Typeable t => t a b c d e f g -> TypeRep typeOf7 _ = I.someTypeRep (Proxy :: Proxy t) diff --git a/libraries/base/Data/Typeable/Internal.hs b/libraries/base/Data/Typeable/Internal.hs index 3b7753de46..09290485e4 100644 --- a/libraries/base/Data/Typeable/Internal.hs +++ b/libraries/base/Data/Typeable/Internal.hs @@ -1,6 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE Trustworthy #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE BangPatterns #-} diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs index bccdab4221..b8f984c440 100644 --- a/libraries/base/GHC/Base.hs +++ b/libraries/base/GHC/Base.hs @@ -84,7 +84,8 @@ Other Prelude modules are much easier with fewer complex dependencies. , ExistentialQuantification , RankNTypes , KindSignatures - , TypeInType + , PolyKinds + , DataKinds #-} -- -Wno-orphans is needed for things like: -- Orphan rule: "x# -# x#" ALWAYS forall x# :: Int# -# x# x# = 0 diff --git a/libraries/base/GHC/Err.hs b/libraries/base/GHC/Err.hs index 3d64c95205..a48fb10a86 100644 --- a/libraries/base/GHC/Err.hs +++ b/libraries/base/GHC/Err.hs @@ -1,6 +1,6 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE NoImplicitPrelude, MagicHash, ImplicitParams #-} -{-# LANGUAGE RankNTypes, TypeInType #-} +{-# LANGUAGE RankNTypes, PolyKinds, DataKinds #-} {-# OPTIONS_HADDOCK hide #-} ----------------------------------------------------------------------------- diff --git a/libraries/base/GHC/Generics.hs b/libraries/base/GHC/Generics.hs index 9ac05286ab..05a96b98eb 100644 --- a/libraries/base/GHC/Generics.hs +++ b/libraries/base/GHC/Generics.hs @@ -15,7 +15,6 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE UndecidableInstances #-} @@ -850,7 +849,7 @@ deriving instance Monoid p => Monoid (Par1 p) -- | Recursive calls of kind @* -> *@ (or kind @k -> *@, when @PolyKinds@ -- is enabled) -newtype Rec1 (f :: k -> *) (p :: k) = Rec1 { unRec1 :: f p } +newtype Rec1 (f :: k -> Type) (p :: k) = Rec1 { unRec1 :: f p } deriving ( Eq -- ^ @since 4.7.0.0 , Ord -- ^ @since 4.7.0.0 , Read -- ^ @since 4.7.0.0 @@ -880,7 +879,7 @@ deriving instance Semigroup (f p) => Semigroup (Rec1 f p) deriving instance Monoid (f p) => Monoid (Rec1 f p) -- | Constants, additional parameters and recursion of kind @*@ -newtype K1 (i :: *) c (p :: k) = K1 { unK1 :: c } +newtype K1 (i :: Type) c (p :: k) = K1 { unK1 :: c } deriving ( Eq -- ^ @since 4.7.0.0 , Ord -- ^ @since 4.7.0.0 , Read -- ^ @since 4.7.0.0 @@ -921,7 +920,8 @@ deriving instance Semigroup (f p) => Semigroup (M1 i c f p) deriving instance Monoid (f p) => Monoid (M1 i c f p) -- | Meta-information (constructor names, etc.) -newtype M1 (i :: *) (c :: Meta) (f :: k -> *) (p :: k) = M1 { unM1 :: f p } +newtype M1 (i :: Type) (c :: Meta) (f :: k -> Type) (p :: k) = + M1 { unM1 :: f p } deriving ( Eq -- ^ @since 4.7.0.0 , Ord -- ^ @since 4.7.0.0 , Read -- ^ @since 4.7.0.0 @@ -933,7 +933,7 @@ newtype M1 (i :: *) (c :: Meta) (f :: k -> *) (p :: k) = M1 { unM1 :: f p } -- | Sums: encode choice between constructors infixr 5 :+: -data (:+:) (f :: k -> *) (g :: k -> *) (p :: k) = L1 (f p) | R1 (g p) +data (:+:) (f :: k -> Type) (g :: k -> Type) (p :: k) = L1 (f p) | R1 (g p) deriving ( Eq -- ^ @since 4.7.0.0 , Ord -- ^ @since 4.7.0.0 , Read -- ^ @since 4.7.0.0 @@ -945,7 +945,7 @@ data (:+:) (f :: k -> *) (g :: k -> *) (p :: k) = L1 (f p) | R1 (g p) -- | Products: encode multiple arguments to constructors infixr 6 :*: -data (:*:) (f :: k -> *) (g :: k -> *) (p :: k) = f p :*: g p +data (:*:) (f :: k -> Type) (g :: k -> Type) (p :: k) = f p :*: g p deriving ( Eq -- ^ @since 4.7.0.0 , Ord -- ^ @since 4.7.0.0 , Read -- ^ @since 4.7.0.0 @@ -986,7 +986,7 @@ instance (Monoid (f p), Monoid (g p)) => Monoid ((f :*: g) p) where -- | Composition of functors infixr 7 :.: -newtype (:.:) (f :: k2 -> *) (g :: k1 -> k2) (p :: k1) = +newtype (:.:) (f :: k2 -> Type) (g :: k1 -> k2) (p :: k1) = Comp1 { unComp1 :: f (g p) } deriving ( Eq -- ^ @since 4.7.0.0 , Ord -- ^ @since 4.7.0.0 @@ -1018,7 +1018,7 @@ deriving instance Monoid (f (g p)) => Monoid ((f :.: g) p) -- | Constants of unlifted kinds -- -- @since 4.9.0.0 -data family URec (a :: *) (p :: k) +data family URec (a :: Type) (p :: k) -- | Used for marking occurrences of 'Addr#' -- @@ -1118,10 +1118,10 @@ type UInt = URec Int -- @since 4.9.0.0 type UWord = URec Word --- | Tag for K1: recursion (of kind @*@) +-- | Tag for K1: recursion (of kind @Type@) data R --- | Type synonym for encoding recursion (of kind @*@) +-- | Type synonym for encoding recursion (of kind @Type@) type Rec0 = K1 R -- | Tag for M1: datatype @@ -1143,17 +1143,17 @@ type S1 = M1 S -- | Class for datatypes that represent datatypes class Datatype d where -- | The name of the datatype (unqualified) - datatypeName :: t d (f :: k -> *) (a :: k) -> [Char] + datatypeName :: t d (f :: k -> Type) (a :: k) -> [Char] -- | The fully-qualified name of the module where the type is declared - moduleName :: t d (f :: k -> *) (a :: k) -> [Char] + moduleName :: t d (f :: k -> Type) (a :: k) -> [Char] -- | The package name of the module where the type is declared -- -- @since 4.9.0.0 - packageName :: t d (f :: k -> *) (a :: k) -> [Char] + packageName :: t d (f :: k -> Type) (a :: k) -> [Char] -- | Marks if the datatype is actually a newtype -- -- @since 4.7.0.0 - isNewtype :: t d (f :: k -> *) (a :: k) -> Bool + isNewtype :: t d (f :: k -> Type) (a :: k) -> Bool isNewtype _ = False -- | @since 4.9.0.0 @@ -1167,14 +1167,14 @@ instance (KnownSymbol n, KnownSymbol m, KnownSymbol p, SingI nt) -- | Class for datatypes that represent data constructors class Constructor c where -- | The name of the constructor - conName :: t c (f :: k -> *) (a :: k) -> [Char] + conName :: t c (f :: k -> Type) (a :: k) -> [Char] -- | The fixity of the constructor - conFixity :: t c (f :: k -> *) (a :: k) -> Fixity + conFixity :: t c (f :: k -> Type) (a :: k) -> Fixity conFixity _ = Prefix -- | Marks if this constructor is a record - conIsRecord :: t c (f :: k -> *) (a :: k) -> Bool + conIsRecord :: t c (f :: k -> Type) (a :: k) -> Bool conIsRecord _ = False -- | @since 4.9.0.0 @@ -1306,19 +1306,19 @@ data DecidedStrictness = DecidedLazy -- | Class for datatypes that represent records class Selector s where -- | The name of the selector - selName :: t s (f :: k -> *) (a :: k) -> [Char] + selName :: t s (f :: k -> Type) (a :: k) -> [Char] -- | The selector's unpackedness annotation (if any) -- -- @since 4.9.0.0 - selSourceUnpackedness :: t s (f :: k -> *) (a :: k) -> SourceUnpackedness + selSourceUnpackedness :: t s (f :: k -> Type) (a :: k) -> SourceUnpackedness -- | The selector's strictness annotation (if any) -- -- @since 4.9.0.0 - selSourceStrictness :: t s (f :: k -> *) (a :: k) -> SourceStrictness + selSourceStrictness :: t s (f :: k -> Type) (a :: k) -> SourceStrictness -- | The strictness that the compiler inferred for the selector -- -- @since 4.9.0.0 - selDecidedStrictness :: t s (f :: k -> *) (a :: k) -> DecidedStrictness + selDecidedStrictness :: t s (f :: k -> Type) (a :: k) -> DecidedStrictness -- | @since 4.9.0.0 instance (SingI mn, SingI su, SingI ss, SingI ds) @@ -1339,7 +1339,7 @@ instance (SingI mn, SingI su, SingI ss, SingI ds) -- @ class Generic a where -- | Generic representation type - type Rep a :: * -> * + type Rep a :: Type -> Type -- | Convert from the datatype to its representation from :: a -> (Rep a) x -- | Convert from the representation to the datatype @@ -1356,9 +1356,9 @@ class Generic a where -- 'from1' . 'to1' ≡ 'id' -- 'to1' . 'from1' ≡ 'id' -- @ -class Generic1 (f :: k -> *) where +class Generic1 (f :: k -> Type) where -- | Generic representation type - type Rep1 f :: k -> * + type Rep1 f :: k -> Type -- | Convert from the datatype to its representation from1 :: f a -> (Rep1 f) a -- | Convert from the representation to the datatype @@ -1490,7 +1490,7 @@ class SingI (a :: k) where class SingKind k where -- | Get a base type from a proxy for the promoted kind. For example, -- @DemoteRep Bool@ will be the type @Bool@. - type DemoteRep k :: * + type DemoteRep k :: Type -- | Convert a singleton to its unrefined version. fromSing :: Sing (a :: k) -> DemoteRep k diff --git a/libraries/base/Type/Reflection/Unsafe.hs b/libraries/base/Type/Reflection/Unsafe.hs index 9a8af16f36..a109400412 100644 --- a/libraries/base/Type/Reflection/Unsafe.hs +++ b/libraries/base/Type/Reflection/Unsafe.hs @@ -12,7 +12,7 @@ -- type representations. -- ----------------------------------------------------------------------------- -{-# LANGUAGE TypeInType, ScopedTypeVariables #-} +{-# LANGUAGE PolyKinds, DataKinds, ScopedTypeVariables #-} module Type.Reflection.Unsafe ( -- * Type representations diff --git a/libraries/base/tests/CatEntail.hs b/libraries/base/tests/CatEntail.hs index c980a2db73..30023ad5b8 100644 --- a/libraries/base/tests/CatEntail.hs +++ b/libraries/base/tests/CatEntail.hs @@ -2,11 +2,11 @@ {-# LANGUAGE TypeOperators, KindSignatures #-} module CatEntail where import Prelude hiding (id, (.)) -import GHC.Exts (Constraint) +import Data.Kind import Control.Category -- One dictionary to rule them all. -data Dict :: Constraint -> * where +data Dict :: Constraint -> Type where Dict :: ctx => Dict ctx -- Entailment. diff --git a/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs b/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs index 518491783f..c01ea32fa8 100644 --- a/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs +++ b/libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs @@ -137,4 +137,5 @@ data Extension | EmptyDataDeriving | NumericUnderscores | QuantifiedConstraints + | StarIsType deriving (Eq, Enum, Show, Generic) diff --git a/libraries/ghc-prim/GHC/Magic.hs b/libraries/ghc-prim/GHC/Magic.hs index 7d6f60e411..ae95bfcbf4 100644 --- a/libraries/ghc-prim/GHC/Magic.hs +++ b/libraries/ghc-prim/GHC/Magic.hs @@ -3,7 +3,8 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE ScopedTypeVariables #-} ----------------------------------------------------------------------------- diff --git a/libraries/ghc-prim/GHC/Types.hs b/libraries/ghc-prim/GHC/Types.hs index ce526b454d..26c92cec83 100644 --- a/libraries/ghc-prim/GHC/Types.hs +++ b/libraries/ghc-prim/GHC/Types.hs @@ -32,7 +32,7 @@ module GHC.Types ( Nat, Symbol, Any, type (~~), Coercible, - TYPE, RuntimeRep(..), Type, type (*), type (★), Constraint, + TYPE, RuntimeRep(..), Type, Constraint, -- The historical type * should ideally be written as -- `type *`, without the parentheses. But that's a true -- pain to parse, and for little gain. @@ -59,12 +59,6 @@ data Constraint -- | The kind of types with values. For example @Int :: Type@. type Type = TYPE 'LiftedRep --- | A backward-compatible (pre-GHC 8.0) synonym for 'Type' -type * = TYPE 'LiftedRep - --- | A unicode backward-compatible (pre-GHC 8.0) synonym for 'Type' -type ★ = TYPE 'LiftedRep - {- ********************************************************************* * * Nat and Symbol diff --git a/testsuite/tests/codeGen/should_fail/T13233.hs b/testsuite/tests/codeGen/should_fail/T13233.hs index fa5a37b046..1facb77914 100644 --- a/testsuite/tests/codeGen/should_fail/T13233.hs +++ b/testsuite/tests/codeGen/should_fail/T13233.hs @@ -1,5 +1,5 @@ {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE MagicHash #-} diff --git a/testsuite/tests/dependent/ghci/T11549.script b/testsuite/tests/dependent/ghci/T11549.script index d8a0e97a61..3e0811f921 100644 --- a/testsuite/tests/dependent/ghci/T11549.script +++ b/testsuite/tests/dependent/ghci/T11549.script @@ -1,4 +1,4 @@ -:set -XTypeInType +:set -XPolyKinds import GHC.Exts putStrLn "-fno-print-explicit-runtime-reps" diff --git a/testsuite/tests/dependent/ghci/T14238.stdout b/testsuite/tests/dependent/ghci/T14238.stdout index fddbc0de54..729f821af7 100644 --- a/testsuite/tests/dependent/ghci/T14238.stdout +++ b/testsuite/tests/dependent/ghci/T14238.stdout @@ -1 +1 @@ -Foo :: forall k -> k -> * +Foo :: forall k -> k -> Type diff --git a/testsuite/tests/dependent/should_compile/Dep1.hs b/testsuite/tests/dependent/should_compile/Dep1.hs index 6f8fe0720d..086d759bbe 100644 --- a/testsuite/tests/dependent/should_compile/Dep1.hs +++ b/testsuite/tests/dependent/should_compile/Dep1.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module Dep1 where diff --git a/testsuite/tests/dependent/should_compile/Dep2.hs b/testsuite/tests/dependent/should_compile/Dep2.hs index df1cb51e08..34be3cffc6 100644 --- a/testsuite/tests/dependent/should_compile/Dep2.hs +++ b/testsuite/tests/dependent/should_compile/Dep2.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, GADTs #-} +{-# LANGUAGE PolyKinds, GADTs #-} module Dep2 where diff --git a/testsuite/tests/dependent/should_compile/Dep3.hs b/testsuite/tests/dependent/should_compile/Dep3.hs index cba5043a08..db10d2a8c6 100644 --- a/testsuite/tests/dependent/should_compile/Dep3.hs +++ b/testsuite/tests/dependent/should_compile/Dep3.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeFamilies, TypeInType, GADTs #-} +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, GADTs #-} module Dep3 where diff --git a/testsuite/tests/dependent/should_compile/DkNameRes.hs b/testsuite/tests/dependent/should_compile/DkNameRes.hs new file mode 100644 index 0000000000..4110b33882 --- /dev/null +++ b/testsuite/tests/dependent/should_compile/DkNameRes.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds #-} + +module DkNameRes where + +import Data.Proxy +import Data.Kind + +type family IfK (e :: Proxy (j :: Bool)) :: Type where + IfK (_ :: Proxy True) = () diff --git a/testsuite/tests/dependent/should_compile/InferDependency.hs b/testsuite/tests/dependent/should_compile/InferDependency.hs deleted file mode 100644 index 47957d47d6..0000000000 --- a/testsuite/tests/dependent/should_compile/InferDependency.hs +++ /dev/null @@ -1,6 +0,0 @@ -{-# LANGUAGE TypeInType #-} - -module InferDependency where - -data Proxy k (a :: k) -data Proxy2 k a = P (Proxy k a) diff --git a/testsuite/tests/dependent/should_compile/KindEqualities.hs b/testsuite/tests/dependent/should_compile/KindEqualities.hs index 4cba8281ca..1caa46f7c3 100644 --- a/testsuite/tests/dependent/should_compile/KindEqualities.hs +++ b/testsuite/tests/dependent/should_compile/KindEqualities.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, GADTs, ExplicitForAll #-} +{-# LANGUAGE PolyKinds, GADTs, ExplicitForAll #-} {-# OPTIONS_GHC -fwarn-incomplete-patterns #-} module KindEqualities where diff --git a/testsuite/tests/dependent/should_compile/KindEqualities2.hs b/testsuite/tests/dependent/should_compile/KindEqualities2.hs index 5a6f60d40b..0bdfcfa034 100644 --- a/testsuite/tests/dependent/should_compile/KindEqualities2.hs +++ b/testsuite/tests/dependent/should_compile/KindEqualities2.hs @@ -1,6 +1,5 @@ {-# LANGUAGE DataKinds, GADTs, PolyKinds, TypeFamilies, ExplicitForAll, - TemplateHaskell, UndecidableInstances, ScopedTypeVariables, - TypeInType #-} + TemplateHaskell, UndecidableInstances, ScopedTypeVariables #-} module KindEqualities2 where diff --git a/testsuite/tests/dependent/should_compile/KindLevels.hs b/testsuite/tests/dependent/should_compile/KindLevels.hs index 1aad299df3..5540ce40cd 100644 --- a/testsuite/tests/dependent/should_compile/KindLevels.hs +++ b/testsuite/tests/dependent/should_compile/KindLevels.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module KindLevels where diff --git a/testsuite/tests/dependent/should_compile/RAE_T32b.hs b/testsuite/tests/dependent/should_compile/RAE_T32b.hs index 7e067099c9..ddd21db18d 100644 --- a/testsuite/tests/dependent/should_compile/RAE_T32b.hs +++ b/testsuite/tests/dependent/should_compile/RAE_T32b.hs @@ -1,23 +1,27 @@ {-# LANGUAGE TemplateHaskell, TypeFamilies, GADTs, DataKinds, PolyKinds, - RankNTypes, TypeOperators, TypeInType #-} + RankNTypes, TypeOperators #-} module RAE_T32b where import Data.Kind -data family Sing (k :: *) :: k -> * +data family Sing (k :: Type) :: k -> Type -data TyArr (a :: *) (b :: *) :: * -type family (a :: TyArr k1 k2 -> *) @@ (b :: k1) :: k2 +data TyArr (a :: Type) (b :: Type) :: Type +type family (a :: TyArr k1 k2 -> Type) @@ (b :: k1) :: k2 $(return []) -data Sigma (p :: *) (r :: TyArr p * -> *) :: * where - Sigma :: forall (p :: *) (r :: TyArr p * -> *) (a :: p) (b :: r @@ a). - Sing * p -> Sing (TyArr p * -> *) r -> Sing p a -> Sing (r @@ a) b -> Sigma p r +data Sigma (p :: Type) (r :: TyArr p Type -> Type) :: Type where + Sigma :: forall (p :: Type) (r :: TyArr p Type -> Type) + (a :: p) (b :: r @@ a). + Sing Type p -> Sing (TyArr p Type -> Type) r -> Sing p a -> + Sing (r @@ a) b -> Sigma p r $(return []) -data instance Sing (Sigma p r) (x :: Sigma p r) :: * where - SSigma :: forall (p :: *) (r :: TyArr p * -> *) (a :: p) (b :: r @@ a) - (sp :: Sing * p) (sr :: Sing (TyArr p * -> *) r) (sa :: Sing p a) (sb :: Sing (r @@ a) b). +data instance Sing (Sigma p r) (x :: Sigma p r) :: Type where + SSigma :: forall (p :: Type) (r :: TyArr p Type -> Type) + (a :: p) (b :: r @@ a) + (sp :: Sing Type p) (sr :: Sing (TyArr p Type -> Type) r) + (sa :: Sing p a) (sb :: Sing (r @@ a) b). Sing (Sing (r @@ a) b) sb -> Sing (Sigma p r) ('Sigma sp sr sa sb) diff --git a/testsuite/tests/dependent/should_compile/Rae31.hs b/testsuite/tests/dependent/should_compile/Rae31.hs index cedc019cf3..7a50b606ee 100644 --- a/testsuite/tests/dependent/should_compile/Rae31.hs +++ b/testsuite/tests/dependent/should_compile/Rae31.hs @@ -1,24 +1,27 @@ {-# LANGUAGE TemplateHaskell, TypeOperators, PolyKinds, DataKinds, - TypeFamilies, TypeInType #-} + TypeFamilies #-} module A where import Data.Kind -data family Sing (k :: *) :: k -> * +data family Sing (k :: Type) :: k -> Type type Sing' (x :: k) = Sing k x -data TyFun' (a :: *) (b :: *) :: * -type TyFun (a :: *) (b :: *) = TyFun' a b -> * +data TyFun' (a :: Type) (b :: Type) :: Type +type TyFun (a :: Type) (b :: Type) = TyFun' a b -> Type type family (a :: TyFun k1 k2) @@ (b :: k1) :: k2 -data TyPi' (a :: *) (b :: TyFun a *) :: * -type TyPi (a :: *) (b :: TyFun a *) = TyPi' a b -> * +data TyPi' (a :: Type) (b :: TyFun a Type) :: Type +type TyPi (a :: Type) (b :: TyFun a Type) = TyPi' a b -> Type type family (a :: TyPi k1 k2) @@@ (b :: k1) :: k2 @@ b $(return []) -data A (a :: *) (b :: a) (c :: TyFun' a *) -- A :: forall a -> a -> a ~> * -type instance (@@) (A a b) c = * +data A (a :: Type) (b :: a) (c :: TyFun' a Type) + -- A :: forall a -> a -> a ~> Type +type instance (@@) (A a b) c = Type $(return []) -data B (a :: *) (b :: TyFun' a *) -- B :: forall a -> a ~> * +data B (a :: Type) (b :: TyFun' a Type) + -- B :: forall a -> a ~> Type type instance (@@) (B a) b = TyPi a (A a b) $(return []) -data C (a :: *) (b :: TyPi a (B a)) (c :: a) (d :: a) (e :: TyFun' (b @@@ c @@@ d) *) +data C (a :: Type) (b :: TyPi a (B a)) (c :: a) (d :: a) + (e :: TyFun' (b @@@ c @@@ d) Type) diff --git a/testsuite/tests/dependent/should_compile/RaeBlogPost.hs b/testsuite/tests/dependent/should_compile/RaeBlogPost.hs index e99c7b5dd5..b048a49e44 100644 --- a/testsuite/tests/dependent/should_compile/RaeBlogPost.hs +++ b/testsuite/tests/dependent/should_compile/RaeBlogPost.hs @@ -1,5 +1,4 @@ -{-# LANGUAGE DataKinds, PolyKinds, GADTs, TypeOperators, TypeFamilies, - TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds, GADTs, TypeOperators, TypeFamilies #-} {-# OPTIONS_GHC -fwarn-unticked-promoted-constructors #-} module RaeBlogPost where @@ -8,7 +7,7 @@ import Data.Kind -- a Proxy type with an explicit kind data Proxy k (a :: k) = P -prox :: Proxy * Bool +prox :: Proxy Type Bool prox = P prox2 :: Proxy Bool 'True @@ -16,11 +15,11 @@ prox2 = P -- implicit kinds still work data A -data B :: A -> * -data C :: B a -> * -data D :: C b -> * -data E :: D c -> * --- note that E :: forall (a :: A) (b :: B a) (c :: C b). D c -> * +data B :: A -> Type +data C :: B a -> Type +data D :: C b -> Type +data E :: D c -> Type +-- note that E :: forall (a :: A) (b :: B a) (c :: C b). D c -> Type -- a kind-indexed GADT data TypeRep (a :: k) where @@ -37,7 +36,7 @@ type family a + b where 'Zero + b = b ('Succ a) + b = 'Succ (a + b) -data Vec :: * -> Nat -> * where +data Vec :: Type -> Nat -> Type where Nil :: Vec a 'Zero (:>) :: a -> Vec a n -> Vec a ('Succ n) infixr 5 :> @@ -47,17 +46,17 @@ type family (x :: Vec a n) ++ (y :: Vec a m) :: Vec a (n + m) where 'Nil ++ y = y (h ':> t) ++ y = h ':> (t ++ y) --- datatype that mentions * -data U = Star (*) +-- datatype that mentions Type +data U = Star (Type) | Bool Bool -- kind synonym -type Monadish = * -> * +type Monadish = Type -> Type class MonadTrans (t :: Monadish -> Monadish) where lift :: Monad m => m a -> t m a data Free :: Monadish where Return :: a -> Free a Bind :: Free a -> (a -> Free b) -> Free b --- yes, * really does have type *. -type Star = (* :: (* :: (* :: *))) +-- yes, Type really does have type Type. +type Star = (Type :: (Type :: (Type :: Type))) diff --git a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs index 480db090c3..1a22573109 100644 --- a/testsuite/tests/dependent/should_compile/RaeJobTalk.hs +++ b/testsuite/tests/dependent/should_compile/RaeJobTalk.hs @@ -3,7 +3,7 @@ {-# LANGUAGE TypeOperators, TypeFamilies, TypeApplications, AllowAmbiguousTypes, ExplicitForAll, ScopedTypeVariables, GADTs, TypeFamilyDependencies, - TypeInType, ConstraintKinds, UndecidableInstances, + DataKinds, PolyKinds , ConstraintKinds, UndecidableInstances, FlexibleInstances, MultiParamTypeClasses, FunctionalDependencies, FlexibleContexts, StandaloneDeriving, InstanceSigs, RankNTypes, UndecidableSuperClasses #-} diff --git a/testsuite/tests/dependent/should_compile/T11405.hs b/testsuite/tests/dependent/should_compile/T11405.hs index cdb713f118..5fdd7baed1 100644 --- a/testsuite/tests/dependent/should_compile/T11405.hs +++ b/testsuite/tests/dependent/should_compile/T11405.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ImplicitParams, TypeInType, ExplicitForAll #-} +{-# LANGUAGE ImplicitParams, PolyKinds, ExplicitForAll #-} module T11405 where diff --git a/testsuite/tests/dependent/should_compile/T11635.hs b/testsuite/tests/dependent/should_compile/T11635.hs index 2292def966..61d9978e55 100644 --- a/testsuite/tests/dependent/should_compile/T11635.hs +++ b/testsuite/tests/dependent/should_compile/T11635.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, KindSignatures, ExplicitForAll, RankNTypes #-} +{-# LANGUAGE PolyKinds, KindSignatures, ExplicitForAll, RankNTypes #-} module T11635 where diff --git a/testsuite/tests/dependent/should_compile/T11711.hs b/testsuite/tests/dependent/should_compile/T11711.hs index 0cd4dceb42..814b2a4a68 100644 --- a/testsuite/tests/dependent/should_compile/T11711.hs +++ b/testsuite/tests/dependent/should_compile/T11711.hs @@ -5,7 +5,6 @@ {-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE FlexibleInstances #-} diff --git a/testsuite/tests/dependent/should_compile/T11719.hs b/testsuite/tests/dependent/should_compile/T11719.hs index ba4d7c9db4..e4c2a89bf2 100644 --- a/testsuite/tests/dependent/should_compile/T11719.hs +++ b/testsuite/tests/dependent/should_compile/T11719.hs @@ -1,12 +1,12 @@ -{-# LANGUAGE RankNTypes, TypeFamilies, TypeInType, TypeOperators, +{-# LANGUAGE RankNTypes, TypeFamilies, TypeOperators, DataKinds, PolyKinds, UndecidableInstances #-} module T11719 where import Data.Kind -data TyFun :: * -> * -> * -type a ~> b = TyFun a b -> * +data TyFun :: Type -> Type -> Type +type a ~> b = TyFun a b -> Type type family (f :: a ~> b) @@ (x :: a) :: b diff --git a/testsuite/tests/dependent/should_compile/T11966.hs b/testsuite/tests/dependent/should_compile/T11966.hs index 0262a0aed3..daad450f13 100644 --- a/testsuite/tests/dependent/should_compile/T11966.hs +++ b/testsuite/tests/dependent/should_compile/T11966.hs @@ -3,7 +3,6 @@ {-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} module T11966 where diff --git a/testsuite/tests/dependent/should_compile/T12176.hs b/testsuite/tests/dependent/should_compile/T12176.hs index 0e340068a7..a11c151567 100644 --- a/testsuite/tests/dependent/should_compile/T12176.hs +++ b/testsuite/tests/dependent/should_compile/T12176.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RankNTypes, TypeInType, GADTs, TypeFamilies #-} +{-# LANGUAGE RankNTypes, DataKinds, PolyKinds, GADTs, TypeFamilies #-} module T12176 where diff --git a/testsuite/tests/dependent/should_compile/T12442.hs b/testsuite/tests/dependent/should_compile/T12442.hs index f9dbf0a486..c76dfb962e 100644 --- a/testsuite/tests/dependent/should_compile/T12442.hs +++ b/testsuite/tests/dependent/should_compile/T12442.hs @@ -1,7 +1,7 @@ -- Based on https://github.com/idris-lang/Idris-dev/blob/v0.9.10/libs/effects/Effects.idr -{-# LANGUAGE TypeInType, ScopedTypeVariables, TypeOperators, TypeApplications, - GADTs, TypeFamilies, AllowAmbiguousTypes #-} +{-# LANGUAGE DataKinds, PolyKinds, ScopedTypeVariables, TypeOperators, + TypeApplications, GADTs, TypeFamilies, AllowAmbiguousTypes #-} module T12442 where diff --git a/testsuite/tests/dependent/should_compile/T12742.hs b/testsuite/tests/dependent/should_compile/T12742.hs index baa3e2c071..988d7c318a 100644 --- a/testsuite/tests/dependent/should_compile/T12742.hs +++ b/testsuite/tests/dependent/should_compile/T12742.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, RankNTypes, TypeFamilies #-} +{-# LANGUAGE DataKinds, PolyKinds, RankNTypes, TypeFamilies #-} module T12742 where diff --git a/testsuite/tests/dependent/should_compile/T13910.hs b/testsuite/tests/dependent/should_compile/T13910.hs index 82d47e45bc..b3707dd365 100644 --- a/testsuite/tests/dependent/should_compile/T13910.hs +++ b/testsuite/tests/dependent/should_compile/T13910.hs @@ -7,7 +7,8 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilyDependencies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T13910 where @@ -17,7 +18,7 @@ import Data.Type.Equality data family Sing (a :: k) class SingKind k where - type Demote k = (r :: *) | r -> k + type Demote k = (r :: Type) | r -> k fromSing :: Sing (a :: k) -> Demote k toSing :: Demote k -> SomeSing k @@ -33,8 +34,8 @@ withSomeSing x f = case toSing x of SomeSing x' -> f x' -data TyFun :: * -> * -> * -type a ~> b = TyFun a b -> * +data TyFun :: Type -> Type -> Type +type a ~> b = TyFun a b -> Type infixr 0 ~> type family Apply (f :: k1 ~> k2) (x :: k1) :: k2 diff --git a/testsuite/tests/dependent/should_compile/T13938.hs b/testsuite/tests/dependent/should_compile/T13938.hs index dd4f3d6c7c..1ce77d194f 100644 --- a/testsuite/tests/dependent/should_compile/T13938.hs +++ b/testsuite/tests/dependent/should_compile/T13938.hs @@ -4,7 +4,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} module T13938 where diff --git a/testsuite/tests/dependent/should_compile/T13938a.hs b/testsuite/tests/dependent/should_compile/T13938a.hs index 3a09292922..5197747e87 100644 --- a/testsuite/tests/dependent/should_compile/T13938a.hs +++ b/testsuite/tests/dependent/should_compile/T13938a.hs @@ -7,7 +7,8 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T13938a where diff --git a/testsuite/tests/dependent/should_compile/T14038.hs b/testsuite/tests/dependent/should_compile/T14038.hs index 839220a0ce..04b24b9f9e 100644 --- a/testsuite/tests/dependent/should_compile/T14038.hs +++ b/testsuite/tests/dependent/should_compile/T14038.hs @@ -6,7 +6,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T14038 where diff --git a/testsuite/tests/dependent/should_compile/T14066a.hs b/testsuite/tests/dependent/should_compile/T14066a.hs index e1a6255520..30b203d31b 100644 --- a/testsuite/tests/dependent/should_compile/T14066a.hs +++ b/testsuite/tests/dependent/should_compile/T14066a.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeFamilies, TypeInType, ExplicitForAll, GADTs, +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, ExplicitForAll, GADTs, UndecidableInstances, RankNTypes, ScopedTypeVariables #-} module T14066a where diff --git a/testsuite/tests/dependent/should_compile/T14556.hs b/testsuite/tests/dependent/should_compile/T14556.hs index eebbdca888..133a9e6a44 100644 --- a/testsuite/tests/dependent/should_compile/T14556.hs +++ b/testsuite/tests/dependent/should_compile/T14556.hs @@ -1,4 +1,5 @@ -{-# Language UndecidableInstances, DataKinds, TypeOperators, KindSignatures, PolyKinds, TypeInType, TypeFamilies, GADTs, LambdaCase, ScopedTypeVariables #-} +{-# Language UndecidableInstances, DataKinds, TypeOperators, PolyKinds, + TypeFamilies, GADTs, LambdaCase, ScopedTypeVariables #-} module T14556 where diff --git a/testsuite/tests/dependent/should_compile/T14720.hs b/testsuite/tests/dependent/should_compile/T14720.hs index c26a184689..0f053756f5 100644 --- a/testsuite/tests/dependent/should_compile/T14720.hs +++ b/testsuite/tests/dependent/should_compile/T14720.hs @@ -3,7 +3,8 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T14720 where diff --git a/testsuite/tests/dependent/should_compile/T14749.hs b/testsuite/tests/dependent/should_compile/T14749.hs index 79bcce66ff..c4480fad0f 100644 --- a/testsuite/tests/dependent/should_compile/T14749.hs +++ b/testsuite/tests/dependent/should_compile/T14749.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, TypeOperators, DataKinds, TypeFamilies, TypeInType #-} +{-# LANGUAGE GADTs, TypeOperators, DataKinds, TypeFamilies, PolyKinds #-} module T14749 where diff --git a/testsuite/tests/dependent/should_compile/T14991.hs b/testsuite/tests/dependent/should_compile/T14991.hs index f435c37690..b2f5642ec5 100644 --- a/testsuite/tests/dependent/should_compile/T14991.hs +++ b/testsuite/tests/dependent/should_compile/T14991.hs @@ -1,5 +1,6 @@ {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} module T14991 where diff --git a/testsuite/tests/dependent/should_compile/T9632.hs b/testsuite/tests/dependent/should_compile/T9632.hs index bea468fff3..f2099aa22b 100644 --- a/testsuite/tests/dependent/should_compile/T9632.hs +++ b/testsuite/tests/dependent/should_compile/T9632.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T9632 where diff --git a/testsuite/tests/dependent/should_compile/TypeLevelVec.hs b/testsuite/tests/dependent/should_compile/TypeLevelVec.hs index 19f605c8cd..0e2f0c7744 100644 --- a/testsuite/tests/dependent/should_compile/TypeLevelVec.hs +++ b/testsuite/tests/dependent/should_compile/TypeLevelVec.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, UnicodeSyntax, GADTs, NoImplicitPrelude, +{-# LANGUAGE DataKinds, PolyKinds, UnicodeSyntax, GADTs, NoImplicitPrelude, TypeOperators, TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-} diff --git a/testsuite/tests/dependent/should_compile/all.T b/testsuite/tests/dependent/should_compile/all.T index e153cafe41..40ba2110f9 100644 --- a/testsuite/tests/dependent/should_compile/all.T +++ b/testsuite/tests/dependent/should_compile/all.T @@ -48,3 +48,4 @@ test('T14720', normal, compile, ['']) test('T14066a', normal, compile, ['']) test('T14749', normal, compile, ['']) test('T14991', normal, compile, ['']) +test('DkNameRes', normal, compile, [''])
\ No newline at end of file diff --git a/testsuite/tests/dependent/should_compile/dynamic-paper.hs b/testsuite/tests/dependent/should_compile/dynamic-paper.hs index 1aa4ee54d9..2c284cfeea 100644 --- a/testsuite/tests/dependent/should_compile/dynamic-paper.hs +++ b/testsuite/tests/dependent/should_compile/dynamic-paper.hs @@ -7,7 +7,7 @@ Stephanie Weirich, Richard Eisenberg, and Dimitrios Vytiniotis, 2016. -} {-# LANGUAGE RankNTypes, PolyKinds, TypeOperators, ScopedTypeVariables, GADTs, FlexibleInstances, UndecidableInstances, RebindableSyntax, - DataKinds, MagicHash, AutoDeriveTypeable, TypeInType #-} + DataKinds, MagicHash, AutoDeriveTypeable #-} {-# OPTIONS_GHC -Wno-missing-methods -Wno-redundant-constraints #-} {-# OPTIONS_GHC -Wno-simplifiable-class-constraints #-} -- Because we define a local Typeable class and have @@ -127,7 +127,7 @@ gcast x = do Refl <- eqT (typeRep :: TypeRep a) (typeRep :: TypeRep b) return x -data SameKind :: k -> k -> * +data SameKind :: k -> k -> Type type CheckAppResult = SameKind AppResult AppResultNoKind -- not the most thorough check foo :: AppResult x -> AppResultNoKind x @@ -170,17 +170,20 @@ dynFst :: Dynamic -> Maybe Dynamic dynFst (Dyn (rpab :: TypeRep pab) (x :: pab)) = do App (rpa :: TypeRep pa ) (rb :: TypeRep b) <- splitApp rpab - -- introduces kind |k2|, and types |pa :: k2 -> *|, |b :: k2| + -- introduces kind |k2|, and types |pa :: k2 -> Type|, |b :: k2| App (rp :: TypeRep p ) (ra :: TypeRep a) <- splitApp rpa - -- introduces kind |k1|, and types |p :: k1 -> k2 -> *|, |a :: k1| + -- introduces kind |k1|, and types |p :: k1 -> k2 -> Type|, + -- |a :: k1| Refl <- eqT rp (typeRep :: TypeRep (,)) - -- introduces |p ~ (,)| and |(k1 -> k2 -> *) ~ (* -> * -> *)| + -- introduces |p ~ (,)| and + -- |(k1 -> k2 -> Type) ~ (Type -> Type -> Type)| return (Dyn ra (fst x)) -eqT :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> Maybe (a :~: b) +eqT :: forall k1 k2 (a :: k1) (b :: k2). + TypeRep a -> TypeRep b -> Maybe (a :~: b) data (a :: k1) :~: (b :: k2) where Refl :: forall k (a :: k). a :~: a @@ -201,11 +204,13 @@ data SomeTypeRep where type TyMapLessTyped = Map SomeTypeRep Dynamic -insertLessTyped :: forall a. Typeable a => a -> TyMapLessTyped -> TyMapLessTyped -insertLessTyped x = Map.insert (SomeTypeRep (typeRep :: TypeRep a)) (toDynamic x) +insertLessTyped :: forall a. Typeable a => a -> TyMapLessTyped -> TyMapLessTyped +insertLessTyped x + = Map.insert (SomeTypeRep (typeRep :: TypeRep a)) (toDynamic x) -lookupLessTyped :: forall a. Typeable a => TyMapLessTyped -> Maybe a -lookupLessTyped = fromDynamic <=< Map.lookup (SomeTypeRep (typeRep :: TypeRep a)) +lookupLessTyped :: forall a. Typeable a => TyMapLessTyped -> Maybe a +lookupLessTyped + = fromDynamic <=< Map.lookup (SomeTypeRep (typeRep :: TypeRep a)) instance Ord SomeTypeRep where compare (SomeTypeRep tr1) (SomeTypeRep tr2) = compareTypeRep tr1 tr2 @@ -329,7 +334,7 @@ dynApplyOld (DynOld trf f) (DynOld trx x) = data DynamicClosed where DynClosed :: TypeRepClosed a -> a -> DynamicClosed -data TypeRepClosed (a :: *) where +data TypeRepClosed (a :: Type) where TBool :: TypeRepClosed Bool TFun :: TypeRepClosed a -> TypeRepClosed b -> TypeRepClosed (a -> b) TProd :: TypeRepClosed a -> TypeRepClosed b -> TypeRepClosed (a, b) diff --git a/testsuite/tests/dependent/should_compile/mkGADTVars.hs b/testsuite/tests/dependent/should_compile/mkGADTVars.hs index 1e74c6980a..9b48e8c395 100644 --- a/testsuite/tests/dependent/should_compile/mkGADTVars.hs +++ b/testsuite/tests/dependent/should_compile/mkGADTVars.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, TypeInType #-} +{-# LANGUAGE GADTs, PolyKinds #-} module GADTVars where diff --git a/testsuite/tests/dependent/should_fail/BadTelescope.hs b/testsuite/tests/dependent/should_fail/BadTelescope.hs index acabffec54..11b52f36e2 100644 --- a/testsuite/tests/dependent/should_fail/BadTelescope.hs +++ b/testsuite/tests/dependent/should_fail/BadTelescope.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module BadTelescope where diff --git a/testsuite/tests/dependent/should_fail/BadTelescope2.hs b/testsuite/tests/dependent/should_fail/BadTelescope2.hs index 6237df4488..b12adbd8e3 100644 --- a/testsuite/tests/dependent/should_fail/BadTelescope2.hs +++ b/testsuite/tests/dependent/should_fail/BadTelescope2.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, ExplicitForAll #-} +{-# LANGUAGE DataKinds, PolyKinds, ExplicitForAll #-} module BadTelescope2 where diff --git a/testsuite/tests/dependent/should_fail/BadTelescope3.hs b/testsuite/tests/dependent/should_fail/BadTelescope3.hs index 807479f634..470f5fb9fe 100644 --- a/testsuite/tests/dependent/should_fail/BadTelescope3.hs +++ b/testsuite/tests/dependent/should_fail/BadTelescope3.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, ExplicitForAll #-} +{-# LANGUAGE PolyKinds, ExplicitForAll #-} module BadTelescope3 where diff --git a/testsuite/tests/dependent/should_fail/BadTelescope4.hs b/testsuite/tests/dependent/should_fail/BadTelescope4.hs index 566922a4a0..bdaf674c2f 100644 --- a/testsuite/tests/dependent/should_fail/BadTelescope4.hs +++ b/testsuite/tests/dependent/should_fail/BadTelescope4.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ExistentialQuantification, TypeInType #-} +{-# LANGUAGE ExistentialQuantification, DataKinds, PolyKinds #-} module BadTelescope4 where import Data.Proxy diff --git a/testsuite/tests/dependent/should_fail/DepFail1.hs b/testsuite/tests/dependent/should_fail/DepFail1.hs index 425a8159c4..26e5d46832 100644 --- a/testsuite/tests/dependent/should_fail/DepFail1.hs +++ b/testsuite/tests/dependent/should_fail/DepFail1.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module DepFail1 where diff --git a/testsuite/tests/dependent/should_fail/InferDependency.hs b/testsuite/tests/dependent/should_fail/InferDependency.hs index 47957d47d6..c2bec19d44 100644 --- a/testsuite/tests/dependent/should_fail/InferDependency.hs +++ b/testsuite/tests/dependent/should_fail/InferDependency.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module InferDependency where diff --git a/testsuite/tests/dependent/should_fail/KindLevelsB.hs b/testsuite/tests/dependent/should_fail/KindLevelsB.hs deleted file mode 100644 index 80762978b2..0000000000 --- a/testsuite/tests/dependent/should_fail/KindLevelsB.hs +++ /dev/null @@ -1,9 +0,0 @@ -{-# LANGUAGE DataKinds, PolyKinds #-} - -module KindLevels where - -data A -data B :: A -> * -data C :: B a -> * -data D :: C b -> * -data E :: D c -> * diff --git a/testsuite/tests/dependent/should_fail/KindLevelsB.stderr b/testsuite/tests/dependent/should_fail/KindLevelsB.stderr deleted file mode 100644 index 587eb97bfa..0000000000 --- a/testsuite/tests/dependent/should_fail/KindLevelsB.stderr +++ /dev/null @@ -1,5 +0,0 @@ - -KindLevelsB.hs:7:13: error: - • Expected kind ‘A’, but ‘a’ has kind ‘*’ - • In the first argument of ‘B’, namely ‘a’ - In the kind ‘B a -> *’ diff --git a/testsuite/tests/dependent/should_fail/PromotedClass.hs b/testsuite/tests/dependent/should_fail/PromotedClass.hs index 6c3f415e5d..53d581015d 100644 --- a/testsuite/tests/dependent/should_fail/PromotedClass.hs +++ b/testsuite/tests/dependent/should_fail/PromotedClass.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, GADTs #-} +{-# LANGUAGE DataKinds, GADTs #-} module PromotedClass where diff --git a/testsuite/tests/dependent/should_fail/RAE_T32a.hs b/testsuite/tests/dependent/should_fail/RAE_T32a.hs index 08a4ad78a8..d71b863f02 100644 --- a/testsuite/tests/dependent/should_fail/RAE_T32a.hs +++ b/testsuite/tests/dependent/should_fail/RAE_T32a.hs @@ -1,34 +1,36 @@ {-# LANGUAGE TemplateHaskell, RankNTypes, TypeOperators, DataKinds, - PolyKinds, TypeFamilies, GADTs, TypeInType #-} + PolyKinds, TypeFamilies, GADTs #-} module RAE_T32a where import Data.Kind -data family Sing (k :: *) :: k -> * +data family Sing (k :: Type) :: k -> Type -data TyArr' (a :: *) (b :: *) :: * -type TyArr (a :: *) (b :: *) = TyArr' a b -> * +data TyArr' (a :: Type) (b :: Type) :: Type +type TyArr (a :: Type) (b :: Type) = TyArr' a b -> Type type family (a :: TyArr k1 k2) @@ (b :: k1) :: k2 -data TyPi' (a :: *) (b :: TyArr a *) :: * -type TyPi (a :: *) (b :: TyArr a *) = TyPi' a b -> * +data TyPi' (a :: Type) (b :: TyArr a Type) :: Type +type TyPi (a :: Type) (b :: TyArr a Type) = TyPi' a b -> Type type family (a :: TyPi k1 k2) @@@ (b :: k1) :: k2 @@ b $(return []) -data MkStar (p :: *) (x :: TyArr' p *) -type instance MkStar p @@ x = * +data MkStar (p :: Type) (x :: TyArr' p Type) +type instance MkStar p @@ x = Type $(return []) -data Sigma (p :: *) (r :: TyPi p (MkStar p)) :: * where +data Sigma (p :: Type) (r :: TyPi p (MkStar p)) :: Type where Sigma :: - forall (p :: *) (r :: TyPi p (MkStar p)) (a :: p) (b :: r @@@ a). - Sing * p -> Sing (TyPi p (MkStar p)) r -> Sing p a -> Sing (r @@@ a) b -> Sigma p r + forall (p :: Type) (r :: TyPi p (MkStar p)) (a :: p) (b :: r @@@ a). + Sing Type p -> Sing (TyPi p (MkStar p)) r -> Sing p a -> + Sing (r @@@ a) b -> Sigma p r $(return []) data instance Sing Sigma (Sigma p r) x where SSigma :: - forall (p :: *) (r :: TyPi p (MkStar p)) (a :: p) (b :: r @@@ a) - (sp :: Sing * p) (sr :: Sing (TyPi p (MkStar p)) r) (sa :: Sing p a) (sb :: Sing (r @@@ a) b). + forall (p :: Type) (r :: TyPi p (MkStar p)) (a :: p) (b :: r @@@ a) + (sp :: Sing Type p) (sr :: Sing (TyPi p (MkStar p)) r) + (sa :: Sing p a) (sb :: Sing (r @@@ a) b). Sing (Sing (r @@@ a) b) sb -> Sing (Sigma p r) ('Sigma sp sr sa sb) diff --git a/testsuite/tests/dependent/should_fail/RAE_T32a.stderr b/testsuite/tests/dependent/should_fail/RAE_T32a.stderr index 046a1e1aa4..41f5d7cd4c 100644 --- a/testsuite/tests/dependent/should_fail/RAE_T32a.stderr +++ b/testsuite/tests/dependent/should_fail/RAE_T32a.stderr @@ -1,10 +1,10 @@ -RAE_T32a.hs:28:1: error: +RAE_T32a.hs:29:1: error: • Expected kind ‘k0 -> *’, but ‘Sing Sigma (Sigma p r)’ has kind ‘*’ • In the data instance declaration for ‘Sing’ -RAE_T32a.hs:28:20: error: +RAE_T32a.hs:29:20: error: • Expecting two more arguments to ‘Sigma’ Expected a type, but ‘Sigma’ has kind @@ -12,7 +12,7 @@ RAE_T32a.hs:28:20: error: • In the first argument of ‘Sing’, namely ‘Sigma’ In the data instance declaration for ‘Sing’ -RAE_T32a.hs:28:27: error: +RAE_T32a.hs:29:27: error: • Expected kind ‘Sigma’, but ‘Sigma p r’ has kind ‘*’ • In the second argument of ‘Sing’, namely ‘(Sigma p r)’ In the data instance declaration for ‘Sing’ diff --git a/testsuite/tests/dependent/should_fail/RenamingStar.hs b/testsuite/tests/dependent/should_fail/RenamingStar.hs index 255021c8d9..f9344b0fd9 100644 --- a/testsuite/tests/dependent/should_fail/RenamingStar.hs +++ b/testsuite/tests/dependent/should_fail/RenamingStar.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE KindSignatures, NoStarIsType #-} module RenamingStar where diff --git a/testsuite/tests/dependent/should_fail/RenamingStar.stderr b/testsuite/tests/dependent/should_fail/RenamingStar.stderr index 5efda699fd..4001811f1f 100644 --- a/testsuite/tests/dependent/should_fail/RenamingStar.stderr +++ b/testsuite/tests/dependent/should_fail/RenamingStar.stderr @@ -1,11 +1,5 @@ RenamingStar.hs:5:13: error: - Not in scope: type constructor or class ‘*’ - NB: With TypeInType, you must import * from Data.Kind - -RenamingStar.hs:5:13: error: - Illegal operator ‘*’ in type ‘*’ - Use TypeOperators to allow operators in types - -RenamingStar.hs:5:13: error: Operator applied to too few arguments: * + With NoStarIsType, ‘*’ is treated as a regular type operator. + Did you mean to use ‘Type’ from Data.Kind instead? diff --git a/testsuite/tests/dependent/should_fail/SelfDep.hs b/testsuite/tests/dependent/should_fail/SelfDep.hs index f54b92752b..22ac9ede98 100644 --- a/testsuite/tests/dependent/should_fail/SelfDep.hs +++ b/testsuite/tests/dependent/should_fail/SelfDep.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE KindSignatures #-} + module SelfDep where data T :: T -> * diff --git a/testsuite/tests/dependent/should_fail/SelfDep.stderr b/testsuite/tests/dependent/should_fail/SelfDep.stderr index f4014f7277..8ac4be8c0c 100644 --- a/testsuite/tests/dependent/should_fail/SelfDep.stderr +++ b/testsuite/tests/dependent/should_fail/SelfDep.stderr @@ -1,5 +1,5 @@ -SelfDep.hs:3:11: error: - Type constructor ‘T’ cannot be used here - (it is defined and used in the same recursive group) - In the kind ‘T -> *’ +SelfDep.hs:5:11: error: + • Type constructor ‘T’ cannot be used here + (it is defined and used in the same recursive group) + • In the kind ‘T -> *’ diff --git a/testsuite/tests/dependent/should_fail/T11407.hs b/testsuite/tests/dependent/should_fail/T11407.hs index 533870f94b..e94eaba1e7 100644 --- a/testsuite/tests/dependent/should_fail/T11407.hs +++ b/testsuite/tests/dependent/should_fail/T11407.hs @@ -1,5 +1,5 @@ {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T11407 where import Data.Kind diff --git a/testsuite/tests/dependent/should_fail/T11473.hs b/testsuite/tests/dependent/should_fail/T11473.hs index 12d95caac6..ebfeeb8a13 100644 --- a/testsuite/tests/dependent/should_fail/T11473.hs +++ b/testsuite/tests/dependent/should_fail/T11473.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE PolyKinds, TypeFamilies, MagicHash, DataKinds, TypeInType, RankNTypes #-} +{-# LANGUAGE PolyKinds, TypeFamilies, MagicHash, DataKinds, RankNTypes #-} module T11473 where diff --git a/testsuite/tests/dependent/should_fail/T12081.hs b/testsuite/tests/dependent/should_fail/T12081.hs index f68de420cb..0bf03b1950 100644 --- a/testsuite/tests/dependent/should_fail/T12081.hs +++ b/testsuite/tests/dependent/should_fail/T12081.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T12081 where diff --git a/testsuite/tests/dependent/should_fail/T12174.hs b/testsuite/tests/dependent/should_fail/T12174.hs index 29064d6a96..800759d690 100644 --- a/testsuite/tests/dependent/should_fail/T12174.hs +++ b/testsuite/tests/dependent/should_fail/T12174.hs @@ -1,7 +1,7 @@ {-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE KindSignatures #-} -{-# LANGUAGE TypeInType #-} module T12174 where data V a diff --git a/testsuite/tests/dependent/should_fail/T13135.hs b/testsuite/tests/dependent/should_fail/T13135.hs index 772ac78bfa..8f78ccbfb1 100644 --- a/testsuite/tests/dependent/should_fail/T13135.hs +++ b/testsuite/tests/dependent/should_fail/T13135.hs @@ -8,11 +8,11 @@ {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeFamilyDependencies #-} -module T12135 where + +module T13135 where import Data.Kind (Type) diff --git a/testsuite/tests/dependent/should_fail/T13601.hs b/testsuite/tests/dependent/should_fail/T13601.hs index 5e98c7a657..a8fa34d4a0 100644 --- a/testsuite/tests/dependent/should_fail/T13601.hs +++ b/testsuite/tests/dependent/should_fail/T13601.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeFamilies, DataKinds, TypeInType #-} +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds #-} import GHC.Exts import Prelude (Bool(True,False),Integer,Ordering,undefined) diff --git a/testsuite/tests/dependent/should_fail/T13780a.hs b/testsuite/tests/dependent/should_fail/T13780a.hs index 1f7c95c40a..b7e1510672 100644 --- a/testsuite/tests/dependent/should_fail/T13780a.hs +++ b/testsuite/tests/dependent/should_fail/T13780a.hs @@ -1,6 +1,6 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T13780a where data family Sing (a :: k) diff --git a/testsuite/tests/dependent/should_fail/T13780b.hs b/testsuite/tests/dependent/should_fail/T13780b.hs index 238e7a1af9..dc6ac89c08 100644 --- a/testsuite/tests/dependent/should_fail/T13780b.hs +++ b/testsuite/tests/dependent/should_fail/T13780b.hs @@ -1,6 +1,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} module T13780b where data family Sing (a :: k) diff --git a/testsuite/tests/dependent/should_fail/T13780c.hs b/testsuite/tests/dependent/should_fail/T13780c.hs index eee6436237..78e09f5ef1 100644 --- a/testsuite/tests/dependent/should_fail/T13780c.hs +++ b/testsuite/tests/dependent/should_fail/T13780c.hs @@ -1,6 +1,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T13780c where import Data.Kind diff --git a/testsuite/tests/dependent/should_fail/T13780c.stderr b/testsuite/tests/dependent/should_fail/T13780c.stderr index 065c700dfc..9a196f4bd7 100644 --- a/testsuite/tests/dependent/should_fail/T13780c.stderr +++ b/testsuite/tests/dependent/should_fail/T13780c.stderr @@ -2,11 +2,13 @@ [2 of 2] Compiling T13780c ( T13780c.hs, T13780c.o ) T13780c.hs:11:16: error: - • Expected kind ‘Sing _1’, but ‘SFalse’ has kind ‘Sing 'False’ + • Data constructor ‘SFalse’ cannot be used here + (it comes from a data family instance) • In the third argument of ‘ElimBool’, namely ‘SFalse’ In the type family declaration for ‘ElimBool’ T13780c.hs:12:16: error: - • Expected kind ‘Sing _1’, but ‘STrue’ has kind ‘Sing 'True’ + • Data constructor ‘STrue’ cannot be used here + (it comes from a data family instance) • In the third argument of ‘ElimBool’, namely ‘STrue’ In the type family declaration for ‘ElimBool’ diff --git a/testsuite/tests/dependent/should_fail/T14066.hs b/testsuite/tests/dependent/should_fail/T14066.hs index 58396df591..709d507a34 100644 --- a/testsuite/tests/dependent/should_fail/T14066.hs +++ b/testsuite/tests/dependent/should_fail/T14066.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE TypeInType #-} -{-# LANGUAGE KindSignatures #-} + + module T14066 where diff --git a/testsuite/tests/dependent/should_fail/T14066c.hs b/testsuite/tests/dependent/should_fail/T14066c.hs index b4597d2cec..4dd6f41973 100644 --- a/testsuite/tests/dependent/should_fail/T14066c.hs +++ b/testsuite/tests/dependent/should_fail/T14066c.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeFamilies, TypeInType, UndecidableInstances #-} +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, UndecidableInstances #-} module T14066c where diff --git a/testsuite/tests/dependent/should_fail/T14066d.hs b/testsuite/tests/dependent/should_fail/T14066d.hs index ea47644688..dd5676826d 100644 --- a/testsuite/tests/dependent/should_fail/T14066d.hs +++ b/testsuite/tests/dependent/should_fail/T14066d.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RankNTypes, ScopedTypeVariables, TypeInType #-} +{-# LANGUAGE RankNTypes, ScopedTypeVariables, PolyKinds #-} module T14066d where diff --git a/testsuite/tests/dependent/should_fail/T14066e.hs b/testsuite/tests/dependent/should_fail/T14066e.hs index 9b799e542c..9bce332527 100644 --- a/testsuite/tests/dependent/should_fail/T14066e.hs +++ b/testsuite/tests/dependent/should_fail/T14066e.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE MonoLocalBinds, TypeInType, ScopedTypeVariables #-} +{-# LANGUAGE MonoLocalBinds, PolyKinds, ScopedTypeVariables #-} module T14066e where diff --git a/testsuite/tests/dependent/should_fail/T14066f.hs b/testsuite/tests/dependent/should_fail/T14066f.hs index ccb7ceac0e..b2035f2c3d 100644 --- a/testsuite/tests/dependent/should_fail/T14066f.hs +++ b/testsuite/tests/dependent/should_fail/T14066f.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T14066f where diff --git a/testsuite/tests/dependent/should_fail/T14066g.hs b/testsuite/tests/dependent/should_fail/T14066g.hs index df0e03b173..b07a2c36a9 100644 --- a/testsuite/tests/dependent/should_fail/T14066g.hs +++ b/testsuite/tests/dependent/should_fail/T14066g.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T14066g where diff --git a/testsuite/tests/dependent/should_fail/T14066h.hs b/testsuite/tests/dependent/should_fail/T14066h.hs index 7e7ecd31c9..a20ae30958 100644 --- a/testsuite/tests/dependent/should_fail/T14066h.hs +++ b/testsuite/tests/dependent/should_fail/T14066h.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ScopedTypeVariables, TypeInType, MonoLocalBinds #-} +{-# LANGUAGE ScopedTypeVariables, PolyKinds, MonoLocalBinds #-} module T14066h where diff --git a/testsuite/tests/dependent/should_fail/T15245.hs b/testsuite/tests/dependent/should_fail/T15245.hs new file mode 100644 index 0000000000..86d9c221e0 --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T15245.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, TypeApplications #-} + +module T15245 where + +import Type.Reflection + +data family K +data instance K = MkK + +main = print (typeRep @'MkK) diff --git a/testsuite/tests/dependent/should_fail/T15245.stderr b/testsuite/tests/dependent/should_fail/T15245.stderr new file mode 100644 index 0000000000..b41076636f --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T15245.stderr @@ -0,0 +1,7 @@ + +T15245.hs:10:24: error: + • Data constructor ‘MkK’ cannot be used here + (it comes from a data family instance) + • In the type ‘ 'MkK’ + In the first argument of ‘print’, namely ‘(typeRep @ 'MkK)’ + In the expression: print (typeRep @ 'MkK) diff --git a/testsuite/tests/dependent/should_fail/TypeSkolEscape.hs b/testsuite/tests/dependent/should_fail/TypeSkolEscape.hs index 02b7737499..1f958de426 100644 --- a/testsuite/tests/dependent/should_fail/TypeSkolEscape.hs +++ b/testsuite/tests/dependent/should_fail/TypeSkolEscape.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RankNTypes, PolyKinds, TypeInType #-} +{-# LANGUAGE RankNTypes, PolyKinds #-} -- NB: -fprint-explicit-runtime-reps enabled in all.T module TypeSkolEscape where diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index 7273445548..5ae037dc54 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -10,7 +10,6 @@ test('BadTelescope4', normal, compile_fail, ['']) test('RenamingStar', normal, compile_fail, ['']) test('T11407', normal, compile_fail, ['']) test('T11334b', normal, compile_fail, ['']) -test('KindLevelsB', normal, compile_fail, ['']) test('T11473', normal, compile_fail, ['']) test('T11471', normal, compile_fail, ['']) test('T12174', normal, compile_fail, ['']) @@ -28,3 +27,4 @@ test('T14066f', normal, compile_fail, ['']) test('T14066g', normal, compile_fail, ['']) test('T14066h', normal, compile_fail, ['']) test('InferDependency', normal, compile_fail, ['']) +test('T15245', normal, compile_fail, ['']) diff --git a/testsuite/tests/dependent/should_run/T11964a.hs b/testsuite/tests/dependent/should_run/T11964a.hs index f0576542b6..2c6993fef0 100644 --- a/testsuite/tests/dependent/should_run/T11964a.hs +++ b/testsuite/tests/dependent/should_run/T11964a.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T11964a where import Data.Kind type Star = Type diff --git a/testsuite/tests/deriving/should_compile/T11416.hs b/testsuite/tests/deriving/should_compile/T11416.hs index 4696306107..210d0423b7 100644 --- a/testsuite/tests/deriving/should_compile/T11416.hs +++ b/testsuite/tests/deriving/should_compile/T11416.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} module T11416 where import Data.Kind diff --git a/testsuite/tests/deriving/should_compile/T11732a.hs b/testsuite/tests/deriving/should_compile/T11732a.hs index 54e1582642..e07fb6aafb 100644 --- a/testsuite/tests/deriving/should_compile/T11732a.hs +++ b/testsuite/tests/deriving/should_compile/T11732a.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T11732a where import GHC.Generics diff --git a/testsuite/tests/deriving/should_compile/T11732b.hs b/testsuite/tests/deriving/should_compile/T11732b.hs index ba71ba5b30..8bd6388063 100644 --- a/testsuite/tests/deriving/should_compile/T11732b.hs +++ b/testsuite/tests/deriving/should_compile/T11732b.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T11732b where data P1 (a :: k) = MkP1 deriving Functor diff --git a/testsuite/tests/deriving/should_compile/T11732c.hs b/testsuite/tests/deriving/should_compile/T11732c.hs index a3034ad867..55553045c0 100644 --- a/testsuite/tests/deriving/should_compile/T11732c.hs +++ b/testsuite/tests/deriving/should_compile/T11732c.hs @@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T11732c where import Data.Kind diff --git a/testsuite/tests/deriving/should_compile/T14331.hs b/testsuite/tests/deriving/should_compile/T14331.hs index 4fe40fad27..d3b52da9a2 100644 --- a/testsuite/tests/deriving/should_compile/T14331.hs +++ b/testsuite/tests/deriving/should_compile/T14331.hs @@ -2,7 +2,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module Bug where class C p q diff --git a/testsuite/tests/deriving/should_compile/T14579.hs b/testsuite/tests/deriving/should_compile/T14579.hs index 19452446d6..518dffe214 100644 --- a/testsuite/tests/deriving/should_compile/T14579.hs +++ b/testsuite/tests/deriving/should_compile/T14579.hs @@ -1,5 +1,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} module T14579 where import Data.Kind diff --git a/testsuite/tests/deriving/should_compile/T14932.hs b/testsuite/tests/deriving/should_compile/T14932.hs index ece83cc497..bb82071bc2 100644 --- a/testsuite/tests/deriving/should_compile/T14932.hs +++ b/testsuite/tests/deriving/should_compile/T14932.hs @@ -5,7 +5,7 @@ {-# LANGUAGE TypeOperators #-} module T14932 where -import GHC.Exts +import Data.Kind (Constraint, Type) class Zero a where zero :: a @@ -16,7 +16,7 @@ type family All c xs :: Constraint where All c '[] = () All c (x : xs) = (c x, All c xs) -type family Code (a :: *) :: [[*]] +type family Code (a :: Type) :: [[Type]] type instance Code B1 = '[ '[ ] ] data B1 = B1 diff --git a/testsuite/tests/deriving/should_fail/T12512.hs b/testsuite/tests/deriving/should_fail/T12512.hs index 4d4e52c06c..804bfd31da 100644 --- a/testsuite/tests/deriving/should_fail/T12512.hs +++ b/testsuite/tests/deriving/should_fail/T12512.hs @@ -1,7 +1,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE UnboxedSums #-} {-# LANGUAGE UnboxedTuples #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T12512 where import GHC.Exts diff --git a/testsuite/tests/deriving/should_fail/T14728a.hs b/testsuite/tests/deriving/should_fail/T14728a.hs index 28cf8e0ffc..5c1d1689dc 100644 --- a/testsuite/tests/deriving/should_fail/T14728a.hs +++ b/testsuite/tests/deriving/should_fail/T14728a.hs @@ -1,7 +1,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T14728a where import Data.Functor.Identity diff --git a/testsuite/tests/deriving/should_fail/T14728b.hs b/testsuite/tests/deriving/should_fail/T14728b.hs index 7fdfcb3b5e..653bcb9252 100644 --- a/testsuite/tests/deriving/should_fail/T14728b.hs +++ b/testsuite/tests/deriving/should_fail/T14728b.hs @@ -1,7 +1,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T14728b where import Data.Functor.Identity diff --git a/testsuite/tests/deriving/should_fail/T15073.hs b/testsuite/tests/deriving/should_fail/T15073.hs index ecceeed5e1..b1da4bb701 100644 --- a/testsuite/tests/deriving/should_fail/T15073.hs +++ b/testsuite/tests/deriving/should_fail/T15073.hs @@ -1,5 +1,5 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T15073 where import T15073a diff --git a/testsuite/tests/determinism/determ004/determ004.hs b/testsuite/tests/determinism/determ004/determ004.hs index 756075031d..1361d76a0e 100644 --- a/testsuite/tests/determinism/determ004/determ004.hs +++ b/testsuite/tests/determinism/determ004/determ004.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeOperators +{-# LANGUAGE TypeOperators, StarIsType , DataKinds , PolyKinds , TypeFamilies diff --git a/testsuite/tests/determinism/determ014/A.hs b/testsuite/tests/determinism/determ014/A.hs index fb7a538ebd..35ea20f225 100644 --- a/testsuite/tests/determinism/determ014/A.hs +++ b/testsuite/tests/determinism/determ014/A.hs @@ -11,6 +11,8 @@ module KeyValue where +import Data.Kind + data AccValidation err a = AccFailure err | AccSuccess a data KeyValueError = MissingValue @@ -23,11 +25,11 @@ missing = rpure missingField missingField :: forall x. (WithKeyValueError :. f) x missingField = Compose $ AccFailure [MissingValue] -data Rec :: (u -> *) -> [u] -> * where +data Rec :: (u -> Type) -> [u] -> Type where RNil :: Rec f '[] (:&) :: !(f r) -> !(Rec f rs) -> Rec f (r ': rs) -newtype Compose (f :: l -> *) (g :: k -> l) (x :: k) +newtype Compose (f :: l -> Type) (g :: k -> l) (x :: k) = Compose { getCompose :: f (g x) } type (:.) f g = Compose f g diff --git a/testsuite/tests/driver/T4437.hs b/testsuite/tests/driver/T4437.hs index 24a46384e6..a75990e5ff 100644 --- a/testsuite/tests/driver/T4437.hs +++ b/testsuite/tests/driver/T4437.hs @@ -42,6 +42,7 @@ expectedGhcOnlyExtensions = ["RelaxedLayout", "DerivingVia", "EmptyDataDeriving", "GeneralisedNewtypeDeriving", + "StarIsType", -- FIXME: add StarIsType to cabal "QuantifiedConstraints"] expectedCabalOnlyExtensions :: [String] diff --git a/testsuite/tests/gadt/T7293.hs b/testsuite/tests/gadt/T7293.hs index 26d9188f81..ed82f2a35b 100644 --- a/testsuite/tests/gadt/T7293.hs +++ b/testsuite/tests/gadt/T7293.hs @@ -3,9 +3,11 @@ module T7294 where +import Data.Kind (Type) + data Nat = Zero | Succ Nat -data Vec :: * -> Nat -> * where +data Vec :: Type -> Nat -> Type where Nil :: Vec a Zero Cons :: a -> Vec a n -> Vec a (Succ n) @@ -14,7 +16,7 @@ type instance m :< Zero = False type instance Zero :< Succ n = True type instance Succ n :< Succ m = n :< m -data SNat :: Nat -> * where +data SNat :: Nat -> Type where SZero :: SNat Zero SSucc :: forall (n :: Nat). SNat n -> SNat (Succ n) diff --git a/testsuite/tests/gadt/T7293.stderr b/testsuite/tests/gadt/T7293.stderr index 664f9a09df..87856d4009 100644 --- a/testsuite/tests/gadt/T7293.stderr +++ b/testsuite/tests/gadt/T7293.stderr @@ -1,9 +1,9 @@ -T7293.hs:24:1: error: [-Woverlapping-patterns (in -Wdefault), -Werror=overlapping-patterns] +T7293.hs:26:1: error: [-Woverlapping-patterns (in -Wdefault), -Werror=overlapping-patterns] Pattern match is redundant In an equation for ‘nth’: nth Nil _ = ... -T7293.hs:24:5: error: [-Winaccessible-code (in -Wdefault), -Werror=inaccessible-code] +T7293.hs:26:5: error: [-Winaccessible-code (in -Wdefault), -Werror=inaccessible-code] • Couldn't match type ‘'True’ with ‘'False’ Inaccessible code in a pattern with constructor: Nil :: forall a. Vec a 'Zero, diff --git a/testsuite/tests/gadt/T7294.hs b/testsuite/tests/gadt/T7294.hs index 1c39a2a574..d7615955a7 100644 --- a/testsuite/tests/gadt/T7294.hs +++ b/testsuite/tests/gadt/T7294.hs @@ -4,9 +4,11 @@ module T7294 where +import Data.Kind (Type) + data Nat = Zero | Succ Nat -data Vec :: * -> Nat -> * where +data Vec :: Type -> Nat -> Type where Nil :: Vec a Zero Cons :: a -> Vec a n -> Vec a (Succ n) @@ -15,7 +17,7 @@ type instance m :< Zero = False type instance Zero :< Succ n = True type instance Succ n :< Succ m = n :< m -data SNat :: Nat -> * where +data SNat :: Nat -> Type where SZero :: SNat Zero SSucc :: forall (n :: Nat). SNat n -> SNat (Succ n) diff --git a/testsuite/tests/gadt/T7294.stderr b/testsuite/tests/gadt/T7294.stderr index 63b3e0e3ef..d7b53ee9e2 100644 --- a/testsuite/tests/gadt/T7294.stderr +++ b/testsuite/tests/gadt/T7294.stderr @@ -1,9 +1,9 @@ -T7294.hs:25:1: warning: [-Woverlapping-patterns (in -Wdefault)] +T7294.hs:27:1: warning: [-Woverlapping-patterns (in -Wdefault)] Pattern match is redundant In an equation for ‘nth’: nth Nil _ = ... -T7294.hs:25:5: warning: [-Winaccessible-code (in -Wdefault)] +T7294.hs:27:5: warning: [-Winaccessible-code (in -Wdefault)] • Couldn't match type ‘'True’ with ‘'False’ Inaccessible code in a pattern with constructor: Nil :: forall a. Vec a 'Zero, diff --git a/testsuite/tests/generics/GEq/GEq1.hs b/testsuite/tests/generics/GEq/GEq1.hs index 54867db8ed..1c7e2ca8c3 100644 --- a/testsuite/tests/generics/GEq/GEq1.hs +++ b/testsuite/tests/generics/GEq/GEq1.hs @@ -3,6 +3,7 @@ module Main where +import Data.Kind import GHC.Exts import GHC.Generics hiding (C, D) import GEq1A @@ -18,14 +19,14 @@ data D a = D0 | D1 { d11 :: a, d12 :: (D a) } data (:**:) a b = a :**: b deriving Generic -data family F a b :: * -> * +data family F a b :: Type -> Type data instance F Int b c = F b Int c deriving Generic data U a = U a Addr# Char# Double# Float# Int# Word# deriving Generic -data family UF a b :: * -> * +data family UF a b :: Type -> Type data instance UF Int b c = UF b c Addr# Char# Double# Float# Int# Word# deriving Generic diff --git a/testsuite/tests/ghci/scripts/T10321.hs b/testsuite/tests/ghci/scripts/T10321.hs index 44d264a801..443ebe41a4 100644 --- a/testsuite/tests/ghci/scripts/T10321.hs +++ b/testsuite/tests/ghci/scripts/T10321.hs @@ -5,9 +5,10 @@ module T10321 where +import Data.Kind (Type) import GHC.TypeLits -data Vec :: Nat -> * -> * where +data Vec :: Nat -> Type -> Type where Nil :: Vec 0 a (:>) :: a -> Vec n a -> Vec (n + 1) a diff --git a/testsuite/tests/ghci/scripts/T11252.script b/testsuite/tests/ghci/scripts/T11252.script index 485cd8fa0d..3cec1d348d 100644 --- a/testsuite/tests/ghci/scripts/T11252.script +++ b/testsuite/tests/ghci/scripts/T11252.script @@ -1,3 +1,3 @@ -:set -XTypeInType +:set -XPolyKinds data Proxy1 k (a :: k) = Proxy1 :kind Proxy1 diff --git a/testsuite/tests/ghci/scripts/T11376.script b/testsuite/tests/ghci/scripts/T11376.script index d359b66542..0cda4f02ba 100644 --- a/testsuite/tests/ghci/scripts/T11376.script +++ b/testsuite/tests/ghci/scripts/T11376.script @@ -3,7 +3,7 @@ let { bar :: Show a => a -> b -> a; bar = error "urk" } :type bar @Int :set -fprint-explicit-foralls :type bar @Int -:set -fprint-explicit-kinds -XTypeApplications -XTypeInType +:set -fprint-explicit-kinds -XTypeApplications -XPolyKinds data Prox a = Prox let { prox :: Prox a; prox = Prox } :t prox diff --git a/testsuite/tests/ghci/scripts/T12550.script b/testsuite/tests/ghci/scripts/T12550.script index dad2a47e65..7c07e8f1dd 100644 --- a/testsuite/tests/ghci/scripts/T12550.script +++ b/testsuite/tests/ghci/scripts/T12550.script @@ -1,4 +1,4 @@ -:set -fprint-explicit-foralls -XKindSignatures -XExplicitNamespaces +:set -fprint-explicit-foralls -XKindSignatures -XExplicitNamespaces -XUnicodeSyntax import Data.Kind (type Type) diff --git a/testsuite/tests/ghci/scripts/T13407.script b/testsuite/tests/ghci/scripts/T13407.script index f77fd42afe..3956a3a210 100644 --- a/testsuite/tests/ghci/scripts/T13407.script +++ b/testsuite/tests/ghci/scripts/T13407.script @@ -1,4 +1,4 @@ -:set -XTypeInType -XRankNTypes +:set -XPolyKinds -XRankNTypes import Data.Kind -data Foo :: (* -> *) -> (forall k. k -> *) +data Foo :: (Type -> Type) -> (forall k. k -> Type) :info Foo diff --git a/testsuite/tests/ghci/scripts/T13963.script b/testsuite/tests/ghci/scripts/T13963.script index fdd4d78338..c5e830aad1 100644 --- a/testsuite/tests/ghci/scripts/T13963.script +++ b/testsuite/tests/ghci/scripts/T13963.script @@ -1,4 +1,4 @@ -:set -XTypeInType -XRankNTypes +:set -XPolyKinds -XDataKinds -XRankNTypes import GHC.Exts (TYPE, RuntimeRep(LiftedRep)) type Pair (a :: TYPE rep) (b :: TYPE rep') rep'' = forall (r :: TYPE rep''). (a -> b -> r) :kind Pair diff --git a/testsuite/tests/ghci/scripts/T13988.hs b/testsuite/tests/ghci/scripts/T13988.hs index 54969cad4d..d26135e26d 100644 --- a/testsuite/tests/ghci/scripts/T13988.hs +++ b/testsuite/tests/ghci/scripts/T13988.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, GADTs #-} +{-# LANGUAGE PolyKinds, GADTs #-} module T13988 where diff --git a/testsuite/tests/ghci/scripts/T7873.script b/testsuite/tests/ghci/scripts/T7873.script index 404c1f5bda..1a358a478e 100644 --- a/testsuite/tests/ghci/scripts/T7873.script +++ b/testsuite/tests/ghci/scripts/T7873.script @@ -1,4 +1,4 @@ -:set -XPolyKinds -XRankNTypes -XGADTs -XTypeInType +:set -XPolyKinds -XRankNTypes -XGADTs data D1 = MkD1 (forall p (a :: k). p a -> Int) data D2 = MkD2 (forall p a. p a -> Int) data D3 = MkD3 (forall k p (a :: k). p a -> Int) diff --git a/testsuite/tests/ghci/scripts/T7939.hs b/testsuite/tests/ghci/scripts/T7939.hs index fbdf883b51..04a1f1a623 100644 --- a/testsuite/tests/ghci/scripts/T7939.hs +++ b/testsuite/tests/ghci/scripts/T7939.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TypeFamilies, PolyKinds, DataKinds, TypeOperators #-} - module T7939 where +import Data.Kind (Type) class Foo a where type Bar a b @@ -22,6 +22,6 @@ type family K a where K '[] = Nothing K (h ': t) = Just h -type family L (a :: k) (b :: *) :: k where +type family L (a :: k) (b :: Type) :: k where L Int Int = Bool L Maybe Bool = IO diff --git a/testsuite/tests/ghci/scripts/T8357.hs b/testsuite/tests/ghci/scripts/T8357.hs index 82a34afdc6..322ec11e19 100644 --- a/testsuite/tests/ghci/scripts/T8357.hs +++ b/testsuite/tests/ghci/scripts/T8357.hs @@ -5,11 +5,12 @@ {-# LANGUAGE TypeOperators #-} module T8357 where +import Data.Kind (Type) import GHC.TypeLits data (:::) (sy :: Symbol) ty data Key (sy :: Symbol) -data Rec (rs :: [*]) +data Rec (rs :: [Type]) (*=) :: Key sy -> ty -> Rec '[sy ::: ty] (*=) = undefined @@ -17,7 +18,7 @@ data Rec (rs :: [*]) (.*.) :: (Union xs ys ~ rs) => Rec xs -> Rec ys -> Rec rs (.*.) = undefined -type family Union (xs :: [*]) (ys :: [*]) :: [*] where +type family Union (xs :: [Type]) (ys :: [Type]) :: [Type] where Union ((sy ::: t) ': xs) ys = (sy ::: t) ': Union xs ys Union '[] ys = ys @@ -30,4 +31,4 @@ fBar = undefined foo = fFoo *= "foo" bar = fBar *= "bar" -both = foo .*. bar
\ No newline at end of file +both = foo .*. bar diff --git a/testsuite/tests/indexed-types/should_compile/HO.hs b/testsuite/tests/indexed-types/should_compile/HO.hs index a674469518..dceb4ebef5 100644 --- a/testsuite/tests/indexed-types/should_compile/HO.hs +++ b/testsuite/tests/indexed-types/should_compile/HO.hs @@ -3,9 +3,10 @@ module HO where import Data.IORef +import Data.Kind -type family SMRef (m::(* -> *)) :: * -> * -type family SMMonad (r::(* -> *)) :: * -> * +type family SMRef (m::(Type -> Type)) :: Type -> Type +type family SMMonad (r::(Type -> Type)) :: Type -> Type type instance SMRef IO = IORef type instance SMMonad IORef = IO diff --git a/testsuite/tests/indexed-types/should_compile/Numerals.hs b/testsuite/tests/indexed-types/should_compile/Numerals.hs index 17fb30c3ca..cb3c8e8e56 100644 --- a/testsuite/tests/indexed-types/should_compile/Numerals.hs +++ b/testsuite/tests/indexed-types/should_compile/Numerals.hs @@ -3,8 +3,9 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} -module Numerals -where +module Numerals where + +import Data.Kind data Z -- empty data type data S a -- empty data type @@ -19,7 +20,7 @@ two = Succ one three = Succ two -- etc...we really would like some nicer syntax here -type family (:+:) n m :: * +type family (:+:) n m :: Type type instance Z :+: m = m type instance (S n) :+: m = S (n :+: m) diff --git a/testsuite/tests/indexed-types/should_compile/T12369.hs b/testsuite/tests/indexed-types/should_compile/T12369.hs index 51cee7df03..7f4e097ca0 100644 --- a/testsuite/tests/indexed-types/should_compile/T12369.hs +++ b/testsuite/tests/indexed-types/should_compile/T12369.hs @@ -1,11 +1,11 @@ -{-# language PolyKinds, KindSignatures, GADTs, TypeFamilies, RankNTypes, TypeInType, +{-# language DataKinds, PolyKinds, GADTs, TypeFamilies, RankNTypes, TypeOperators, ConstraintKinds #-} module T12369 where import Data.Kind -data family Fix :: (k -> *) -> k +data family Fix :: (k -> Type) -> k newtype instance Fix f = In { out :: f (Fix f) } type FREE k = (k -> Constraint) -> (k -> k) diff --git a/testsuite/tests/indexed-types/should_compile/T12522b.hs b/testsuite/tests/indexed-types/should_compile/T12522b.hs index 75013823c9..7ed8ae19ff 100644 --- a/testsuite/tests/indexed-types/should_compile/T12522b.hs +++ b/testsuite/tests/indexed-types/should_compile/T12522b.hs @@ -3,15 +3,17 @@ {-# LANGUAGE TypeFamilyDependencies #-} {-# LANGUAGE TypeOperators #-} -module T12522a where +module T12522b where + +import Data.Kind (Type) newtype I a = I a -type family Curry (as :: [*]) b = f | f -> as b where +type family Curry (as :: [Type]) b = f | f -> as b where Curry '[] b = I b Curry (a:as) b = a -> Curry as b -data Uncurried (as :: [*]) b +data Uncurried (as :: [Type]) b def :: Curry as b -> Uncurried as b def = undefined diff --git a/testsuite/tests/indexed-types/should_compile/T12938.hs b/testsuite/tests/indexed-types/should_compile/T12938.hs index 1c8f47e8cb..262a66b406 100644 --- a/testsuite/tests/indexed-types/should_compile/T12938.hs +++ b/testsuite/tests/indexed-types/should_compile/T12938.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, TypeFamilies #-} +{-# LANGUAGE PolyKinds, TypeFamilies #-} module Bug where diff --git a/testsuite/tests/indexed-types/should_compile/T13244.hs b/testsuite/tests/indexed-types/should_compile/T13244.hs index e1a65b99ef..6cfea014a4 100644 --- a/testsuite/tests/indexed-types/should_compile/T13244.hs +++ b/testsuite/tests/indexed-types/should_compile/T13244.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE MagicHash, DataKinds, PolyKinds, TypeInType, TypeFamilies #-} +{-# LANGUAGE MagicHash, DataKinds, PolyKinds, TypeFamilies #-} module T13244 where diff --git a/testsuite/tests/indexed-types/should_compile/T13398b.hs b/testsuite/tests/indexed-types/should_compile/T13398b.hs index 0689ef39d6..703a81763a 100644 --- a/testsuite/tests/indexed-types/should_compile/T13398b.hs +++ b/testsuite/tests/indexed-types/should_compile/T13398b.hs @@ -1,5 +1,5 @@ {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T13398b where import GHC.TypeLits diff --git a/testsuite/tests/indexed-types/should_compile/T14162.hs b/testsuite/tests/indexed-types/should_compile/T14162.hs index 136c161cbf..1eccbffc86 100644 --- a/testsuite/tests/indexed-types/should_compile/T14162.hs +++ b/testsuite/tests/indexed-types/should_compile/T14162.hs @@ -1,4 +1,5 @@ -{-# Language TypeOperators, KindSignatures, DataKinds, PolyKinds, TypeFamilies, GADTs, TypeInType #-} +{-# Language TypeOperators, KindSignatures, DataKinds, PolyKinds, + TypeFamilies, GADTs #-} module T14162 where diff --git a/testsuite/tests/indexed-types/should_compile/T14554.hs b/testsuite/tests/indexed-types/should_compile/T14554.hs index f6b382252a..6049b1934e 100644 --- a/testsuite/tests/indexed-types/should_compile/T14554.hs +++ b/testsuite/tests/indexed-types/should_compile/T14554.hs @@ -1,6 +1,5 @@ -{-# Language UndecidableInstances, DataKinds, TypeOperators, - KindSignatures, PolyKinds, TypeInType, TypeFamilies, - GADTs, LambdaCase, ScopedTypeVariables #-} +{-# Language UndecidableInstances, DataKinds, TypeOperators, TypeFamilies, + PolyKinds, GADTs, LambdaCase, ScopedTypeVariables #-} module T14554 where diff --git a/testsuite/tests/indexed-types/should_compile/T15122.hs b/testsuite/tests/indexed-types/should_compile/T15122.hs index 44a3c0523f..c05bd3a8a0 100644 --- a/testsuite/tests/indexed-types/should_compile/T15122.hs +++ b/testsuite/tests/indexed-types/should_compile/T15122.hs @@ -7,7 +7,7 @@ import Data.Kind import Data.Proxy data IsStar (a :: k) where - IsStar :: IsStar (a :: *) + IsStar :: IsStar (a :: Type) type family F (a :: k) :: k diff --git a/testsuite/tests/indexed-types/should_compile/T2219.hs b/testsuite/tests/indexed-types/should_compile/T2219.hs index ea7d442f74..9778524a7a 100644 --- a/testsuite/tests/indexed-types/should_compile/T2219.hs +++ b/testsuite/tests/indexed-types/should_compile/T2219.hs @@ -2,6 +2,8 @@ module Test where +import Data.Kind (Type) + data Zero data Succ a @@ -15,7 +17,7 @@ data Fin n fn where data Nil data a ::: b -type family Lookup ts fn :: * +type family Lookup ts fn :: Type type instance Lookup (t ::: ts) FZ = t type instance Lookup (t ::: ts) (FS fn) = Lookup ts fn diff --git a/testsuite/tests/indexed-types/should_compile/T7585.hs b/testsuite/tests/indexed-types/should_compile/T7585.hs index a21c04dbf7..2cf23d267e 100644 --- a/testsuite/tests/indexed-types/should_compile/T7585.hs +++ b/testsuite/tests/indexed-types/should_compile/T7585.hs @@ -3,11 +3,13 @@ module Bug where -data SBool :: Bool -> * where +import Data.Kind + +data SBool :: Bool -> Type where SFalse :: SBool False STrue :: SBool True -data SList :: [Bool] -> * where +data SList :: [Bool] -> Type where SNil :: SList '[] SCons :: SBool h -> SList t -> SList (h ': t) @@ -17,4 +19,4 @@ type family (a :: [k]) :==: (b :: [k]) :: Bool where a :==: b = False (%==%) :: SList ls1 -> SList ls2 -> SBool (ls1 :==: ls2) -SNil %==% (SCons _ _) = SFalse
\ No newline at end of file +SNil %==% (SCons _ _) = SFalse diff --git a/testsuite/tests/indexed-types/should_compile/T9747.hs b/testsuite/tests/indexed-types/should_compile/T9747.hs index 3b1c47703e..aefffd55f6 100644 --- a/testsuite/tests/indexed-types/should_compile/T9747.hs +++ b/testsuite/tests/indexed-types/should_compile/T9747.hs @@ -4,13 +4,14 @@ module T9747 where import Data.List (intercalate) import Data.Proxy -import GHC.Exts (Constraint) +import Data.Kind (Type, Constraint) -data HList :: [*] -> * where +data HList :: [Type] -> Type where Nil :: HList '[] Cons :: a -> HList as -> HList (a ': as) -type family HListAll (c :: * -> Constraint) (ts :: [*]) :: Constraint where +type family HListAll (c :: Type -> Constraint) + (ts :: [Type]) :: Constraint where HListAll c '[] = () HListAll c (t ': ts) = (c t, HListAll c ts) @@ -27,7 +28,7 @@ test = showHList (Cons (2::Int) (Cons (3.1 :: Float) (Cons 'c' Nil))) -type family ConFun (t :: *) :: * -> Constraint +type family ConFun (t :: Type) :: Type -> Constraint data Tag type instance ConFun Tag = Group diff --git a/testsuite/tests/indexed-types/should_fail/T12522a.hs b/testsuite/tests/indexed-types/should_fail/T12522a.hs index eb855f4171..e8b12c4d1e 100644 --- a/testsuite/tests/indexed-types/should_fail/T12522a.hs +++ b/testsuite/tests/indexed-types/should_fail/T12522a.hs @@ -5,13 +5,15 @@ module T12522a where +import Data.Kind (Type) + newtype I a = I a -type family Curry (as :: [*]) b = f | f -> as b where +type family Curry (as :: [Type]) b = f | f -> as b where Curry '[] b = I b Curry (a:as) b = a -> Curry as b -data Uncurried (as :: [*]) b +data Uncurried (as :: [Type]) b def :: Curry as b -> Uncurried as b def = undefined diff --git a/testsuite/tests/indexed-types/should_fail/T12522a.stderr b/testsuite/tests/indexed-types/should_fail/T12522a.stderr index d7a4f06b8c..44e60d2194 100644 --- a/testsuite/tests/indexed-types/should_fail/T12522a.stderr +++ b/testsuite/tests/indexed-types/should_fail/T12522a.stderr @@ -1,10 +1,10 @@ -T12522a.hs:20:26: error: +T12522a.hs:22:26: error: • Ambiguous type variable ‘a0’ arising from a use of ‘show’ prevents the constraint ‘(Show a0)’ from being solved. Relevant bindings include - n :: a0 (bound at T12522a.hs:20:15) - test :: Uncurried '[a0, [Char]] [Char] (bound at T12522a.hs:20:1) + n :: a0 (bound at T12522a.hs:22:15) + test :: Uncurried '[a0, [Char]] [Char] (bound at T12522a.hs:22:1) Probable fix: use a type annotation to specify what ‘a0’ should be. These potential instances exist: instance Show Ordering -- Defined in ‘GHC.Show’ diff --git a/testsuite/tests/indexed-types/should_fail/T13674.hs b/testsuite/tests/indexed-types/should_fail/T13674.hs index 4d9a81d8a5..2951406241 100644 --- a/testsuite/tests/indexed-types/should_fail/T13674.hs +++ b/testsuite/tests/indexed-types/should_fail/T13674.hs @@ -11,11 +11,11 @@ module T13674 where import Data.Proxy -import GHC.Exts (Constraint) +import Data.Kind (Constraint, Type) import GHC.TypeLits import Unsafe.Coerce (unsafeCoerce) -data Dict :: Constraint -> * where +data Dict :: Constraint -> Type where Dict :: a => Dict a infixr 9 :- diff --git a/testsuite/tests/indexed-types/should_fail/T13784.hs b/testsuite/tests/indexed-types/should_fail/T13784.hs index 36c72b98af..48982769a2 100644 --- a/testsuite/tests/indexed-types/should_fail/T13784.hs +++ b/testsuite/tests/indexed-types/should_fail/T13784.hs @@ -4,9 +4,10 @@ module T13784 where +import Data.Kind (Type) import Data.Monoid ((<>)) -data Product :: [*] -> * where +data Product :: [Type] -> Type where (:*) :: a -> Product as -> Product (a : as) Unit :: Product '[] infixr 5 :* @@ -18,7 +19,7 @@ instance (Show a, Show (Product as)) => Show (Product (a : as)) where show (a :* as) = show a <> " :* " <> show as class Divideable a as where - type Divide a as :: [*] + type Divide a as :: [Type] divide :: Product as -> (a, Product (Divide a as)) instance Divideable a (a : as) where diff --git a/testsuite/tests/indexed-types/should_fail/T13784.stderr b/testsuite/tests/indexed-types/should_fail/T13784.stderr index ee4ec20b63..63edf0482f 100644 --- a/testsuite/tests/indexed-types/should_fail/T13784.stderr +++ b/testsuite/tests/indexed-types/should_fail/T13784.stderr @@ -1,9 +1,9 @@ -T13784.hs:28:28: error: +T13784.hs:29:28: error: • Couldn't match type ‘as’ with ‘a : Divide a as’ ‘as’ is a rigid type variable bound by the instance declaration - at T13784.hs:24:10-30 + at T13784.hs:25:10-30 Expected type: Product (Divide a (a : as)) Actual type: Product as1 • In the expression: as @@ -11,9 +11,9 @@ T13784.hs:28:28: error: In an equation for ‘divide’: divide (a :* as) = (a, as) • Relevant bindings include divide :: Product (a : as) -> (a, Product (Divide a (a : as))) - (bound at T13784.hs:28:5) + (bound at T13784.hs:29:5) -T13784.hs:32:24: error: +T13784.hs:33:24: error: • Couldn't match type ‘Product (a : as0)’ with ‘(b, Product (Divide b (a : as)))’ Expected type: (b, Product (Divide b (a : as))) @@ -23,9 +23,9 @@ T13784.hs:32:24: error: In the instance declaration for ‘Divideable b (a : as)’ • Relevant bindings include divide :: Product (a : as) -> (b, Product (Divide b (a : as))) - (bound at T13784.hs:32:5) + (bound at T13784.hs:33:5) -T13784.hs:32:29: error: +T13784.hs:33:29: error: • Couldn't match type ‘(a0, Product (Divide a0 as))’ with ‘Product as0’ Expected type: Product as0 @@ -35,4 +35,4 @@ T13784.hs:32:29: error: In an equation for ‘divide’: divide (a :* as) = a :* divide as • Relevant bindings include divide :: Product (a : as) -> (b, Product (Divide b (a : as))) - (bound at T13784.hs:32:5) + (bound at T13784.hs:33:5) diff --git a/testsuite/tests/indexed-types/should_fail/T13877.hs b/testsuite/tests/indexed-types/should_fail/T13877.hs index ee5f16b1f3..89c79a60e3 100644 --- a/testsuite/tests/indexed-types/should_fail/T13877.hs +++ b/testsuite/tests/indexed-types/should_fail/T13877.hs @@ -6,7 +6,7 @@ {-# LANGUAGE Trustworthy #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T13877 where @@ -17,8 +17,8 @@ data instance Sing (z :: [a]) where SNil :: Sing '[] SCons :: Sing x -> Sing xs -> Sing (x:xs) -data TyFun :: * -> * -> * -type a ~> b = TyFun a b -> * +data TyFun :: Type -> Type -> Type +type a ~> b = TyFun a b -> Type infixr 0 ~> type family Apply (f :: k1 ~> k2) (x :: k1) :: k2 diff --git a/testsuite/tests/indexed-types/should_fail/T13972.hs b/testsuite/tests/indexed-types/should_fail/T13972.hs index 8a43e2016f..a0a203d30a 100644 --- a/testsuite/tests/indexed-types/should_fail/T13972.hs +++ b/testsuite/tests/indexed-types/should_fail/T13972.hs @@ -1,6 +1,6 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} module Bug where import Data.Kind diff --git a/testsuite/tests/indexed-types/should_fail/T14175.hs b/testsuite/tests/indexed-types/should_fail/T14175.hs index 9d259fe704..2e84b730e1 100644 --- a/testsuite/tests/indexed-types/should_fail/T14175.hs +++ b/testsuite/tests/indexed-types/should_fail/T14175.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeFamilies, PolyKinds, TypeInType #-} +{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds #-} module T14175 where diff --git a/testsuite/tests/indexed-types/should_fail/T14246.hs b/testsuite/tests/indexed-types/should_fail/T14246.hs index cf947e816e..6ae8760c84 100644 --- a/testsuite/tests/indexed-types/should_fail/T14246.hs +++ b/testsuite/tests/indexed-types/should_fail/T14246.hs @@ -2,7 +2,7 @@ module T14246 where -import Data.Kind -- necessary for * +import Data.Kind data Nat = Z | S Nat @@ -16,8 +16,8 @@ data L type family KLN (n :: k) :: Nat where KLN (f :: v -> k) = S (KLN (forall t. f t)) - KLN (f :: *) = Z + KLN (f :: Type) = Z -type family Reveal (n :: k) (l :: Vect (KLN n) L) :: * where +type family Reveal (n :: k) (l :: Vect (KLN n) L) :: Type where Reveal (f :: v -> k) (Cons (Label (t :: v)) l) = Reveal (f t) l - Reveal (a :: *) Nil = a + Reveal (a :: Type) Nil = a diff --git a/testsuite/tests/indexed-types/should_fail/T14246.stderr b/testsuite/tests/indexed-types/should_fail/T14246.stderr index 0f0a3e579d..4bb45d6399 100644 --- a/testsuite/tests/indexed-types/should_fail/T14246.stderr +++ b/testsuite/tests/indexed-types/should_fail/T14246.stderr @@ -18,7 +18,7 @@ T14246.hs:22:67: error: In the type ‘Reveal (f t) l’ In the type family declaration for ‘Reveal’ -T14246.hs:23:21: error: +T14246.hs:23:24: error: • Expected kind ‘Vect (KLN a) L’, but ‘Nil’ has kind ‘Vect 'Z L’ • In the second argument of ‘Reveal’, namely ‘Nil’ In the type family declaration for ‘Reveal’ diff --git a/testsuite/tests/indexed-types/should_fail/T14369.hs b/testsuite/tests/indexed-types/should_fail/T14369.hs index 98afa3ecd6..ef5166c318 100644 --- a/testsuite/tests/indexed-types/should_fail/T14369.hs +++ b/testsuite/tests/indexed-types/should_fail/T14369.hs @@ -4,7 +4,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilyDependencies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T14369 where diff --git a/testsuite/tests/indexed-types/should_fail/T2544.hs b/testsuite/tests/indexed-types/should_fail/T2544.hs index 2150cd5775..34a79f4db8 100644 --- a/testsuite/tests/indexed-types/should_fail/T2544.hs +++ b/testsuite/tests/indexed-types/should_fail/T2544.hs @@ -4,10 +4,12 @@ module T2544 where +import Data.Kind + data (:|:) a b = Inl a | Inr b class Ix i where - type IxMap i :: * -> * + type IxMap i :: Type -> Type empty :: IxMap i [Int] data BiApp a b c = BiApp (a c) (b c) diff --git a/testsuite/tests/indexed-types/should_fail/T2544.stderr b/testsuite/tests/indexed-types/should_fail/T2544.stderr index d5a9c56516..93d7746066 100644 --- a/testsuite/tests/indexed-types/should_fail/T2544.stderr +++ b/testsuite/tests/indexed-types/should_fail/T2544.stderr @@ -1,5 +1,5 @@ -T2544.hs:17:12: error: +T2544.hs:19:12: error: • Couldn't match type ‘IxMap r’ with ‘IxMap i1’ Expected type: IxMap (l :|: r) [Int] Actual type: BiApp (IxMap l) (IxMap i1) [Int] @@ -9,9 +9,9 @@ T2544.hs:17:12: error: In an equation for ‘empty’: empty = BiApp empty empty In the instance declaration for ‘Ix (l :|: r)’ • Relevant bindings include - empty :: IxMap (l :|: r) [Int] (bound at T2544.hs:17:4) + empty :: IxMap (l :|: r) [Int] (bound at T2544.hs:19:4) -T2544.hs:17:18: error: +T2544.hs:19:18: error: • Couldn't match type ‘IxMap i0’ with ‘IxMap l’ Expected type: IxMap l [Int] Actual type: IxMap i0 [Int] @@ -21,4 +21,4 @@ T2544.hs:17:18: error: In the expression: BiApp empty empty In an equation for ‘empty’: empty = BiApp empty empty • Relevant bindings include - empty :: IxMap (l :|: r) [Int] (bound at T2544.hs:17:4) + empty :: IxMap (l :|: r) [Int] (bound at T2544.hs:19:4) diff --git a/testsuite/tests/indexed-types/should_fail/T3330c.hs b/testsuite/tests/indexed-types/should_fail/T3330c.hs index e6c4dfbb30..d84c51d5d5 100644 --- a/testsuite/tests/indexed-types/should_fail/T3330c.hs +++ b/testsuite/tests/indexed-types/should_fail/T3330c.hs @@ -2,9 +2,11 @@ module T3330c where +import Data.Kind + data (f :+: g) x = Inl (f x) | Inr (g x) -data R :: (* -> *) -> * where +data R :: (Type -> Type) -> Type where RSum :: R f -> R g -> R (f :+: g) class Rep f where @@ -13,7 +15,7 @@ class Rep f where instance (Rep f, Rep g) => Rep (f :+: g) where rep = RSum rep rep -type family Der (f :: * -> *) :: * -> * +type family Der (f :: Type -> Type) :: Type -> Type type instance Der (f :+: g) = Der f :+: Der g plug :: Rep f => Der f x -> x -> f x @@ -55,4 +57,4 @@ Hence f1 ~ f1 x --}
\ No newline at end of file +-} diff --git a/testsuite/tests/indexed-types/should_fail/T3330c.stderr b/testsuite/tests/indexed-types/should_fail/T3330c.stderr index 829bca1400..4ef5ae66a8 100644 --- a/testsuite/tests/indexed-types/should_fail/T3330c.stderr +++ b/testsuite/tests/indexed-types/should_fail/T3330c.stderr @@ -1,5 +1,5 @@ -T3330c.hs:23:43: error: +T3330c.hs:25:43: error: • Couldn't match kind ‘* -> *’ with ‘*’ When matching types f1 :: * -> * @@ -10,7 +10,7 @@ T3330c.hs:23:43: error: In the first argument of ‘Inl’, namely ‘(plug rf df x)’ In the expression: Inl (plug rf df x) • Relevant bindings include - x :: x (bound at T3330c.hs:23:29) - df :: f1 x (bound at T3330c.hs:23:25) - rf :: R f1 (bound at T3330c.hs:23:13) - plug' :: R f -> Der f x -> x -> f x (bound at T3330c.hs:23:1) + x :: x (bound at T3330c.hs:25:29) + df :: f1 x (bound at T3330c.hs:25:25) + rf :: R f1 (bound at T3330c.hs:25:13) + plug' :: R f -> Der f x -> x -> f x (bound at T3330c.hs:25:1) diff --git a/testsuite/tests/indexed-types/should_fail/T4174.hs b/testsuite/tests/indexed-types/should_fail/T4174.hs index 784c0baa08..a4f105ff86 100644 --- a/testsuite/tests/indexed-types/should_fail/T4174.hs +++ b/testsuite/tests/indexed-types/should_fail/T4174.hs @@ -2,6 +2,8 @@ module T4174 where +import Data.Kind (Type) + data True data False @@ -10,17 +12,17 @@ data Minor1 data GHC6'8 m data GHC6'10 m -type family a :<=: b :: {-Bool-}* +type family a :<=: b :: {-Bool-} Type type instance GHC6'10 m1 :<=: GHC6'8 m2 = False type a :>=: b = b :<=: a data Way ghcVersion tablesNextToCode profiling threaded -type family GHCVersion way :: {-GHCVersion-} * +type family GHCVersion way :: {-GHCVersion-} Type type instance GHCVersion (Way v n p t) = v -type family Threaded way :: {-Bool-} * +type family Threaded way :: {-Bool-} Type type instance Threaded (Way v n p t) = t data Field w s t @@ -30,7 +32,7 @@ data RtsSpinLock field :: String -> m (Field w a b) field = undefined -type family WayOf (m :: * -> *) :: * +type family WayOf (m :: Type -> Type) :: Type sync_large_objects :: (Monad m, (GHCVersion (WayOf m) :>=: GHC6'10 Minor1) ~ True, @@ -57,4 +59,4 @@ testcase = sync_large_objects == (GHC6'10 Minor1 :<=: GHC6'8 minor) ~ True == False ~ True --}
\ No newline at end of file +-} diff --git a/testsuite/tests/indexed-types/should_fail/T4174.stderr b/testsuite/tests/indexed-types/should_fail/T4174.stderr index db5008dd1e..ccc88ced1e 100644 --- a/testsuite/tests/indexed-types/should_fail/T4174.stderr +++ b/testsuite/tests/indexed-types/should_fail/T4174.stderr @@ -1,16 +1,16 @@ -T4174.hs:42:12: error: +T4174.hs:44:12: error: • Couldn't match type ‘b’ with ‘RtsSpinLock’ ‘b’ is a rigid type variable bound by the type signature for: testcase :: forall (m :: * -> *) minor n t p a b. Monad m => m (Field (Way (GHC6'8 minor) n t p) a b) - at T4174.hs:41:1-63 + at T4174.hs:43:1-63 Expected type: m (Field (Way (GHC6'8 minor) n t p) a b) Actual type: m (Field (WayOf m) SmStep RtsSpinLock) • In the expression: sync_large_objects In an equation for ‘testcase’: testcase = sync_large_objects • Relevant bindings include testcase :: m (Field (Way (GHC6'8 minor) n t p) a b) - (bound at T4174.hs:42:1) + (bound at T4174.hs:44:1) diff --git a/testsuite/tests/indexed-types/should_fail/T7786.hs b/testsuite/tests/indexed-types/should_fail/T7786.hs index 2a5c7f5983..33a74f233f 100644 --- a/testsuite/tests/indexed-types/should_fail/T7786.hs +++ b/testsuite/tests/indexed-types/should_fail/T7786.hs @@ -4,7 +4,9 @@ FlexibleContexts, ScopedTypeVariables #-} module T7786 where +import Data.Kind (Type) import GHC.TypeLits(Symbol,Nat) + data family Sing (a :: k) data Inventory a = Empty | More (Inventory a) a @@ -33,7 +35,7 @@ under Root' post = post under (Symic'' ks k) post = under ks post `Symic''` k under (Numic'' ks k) post = under ks post `Numic''` k -data Database :: Inventory [KeySegment] -> * where +data Database :: Inventory [KeySegment] -> Type where Clean :: Database Empty Record :: (k `KeyNotIn` i) => Database i -> Sing k -> () -> Database (More i k) Sub :: ((sub `UnderDisjoint` k) i) => Database i -> Sing k -> Database sub -> Database ((sub `BuriedUnder` k) i) diff --git a/testsuite/tests/indexed-types/should_fail/T7786.stderr b/testsuite/tests/indexed-types/should_fail/T7786.stderr index 89984ca6b0..af9ca89b7e 100644 --- a/testsuite/tests/indexed-types/should_fail/T7786.stderr +++ b/testsuite/tests/indexed-types/should_fail/T7786.stderr @@ -1,5 +1,5 @@ -T7786.hs:94:41: error: +T7786.hs:96:41: error: • Couldn't match type ‘xxx’ with ‘Intersect (BuriedUnder sub k 'Empty) inv’ Expected type: Maybe (Sing xxx) @@ -14,36 +14,35 @@ T7786.hs:94:41: error: = do Nil :: Sing xxx <- foogle db k sub return $ Sub db k sub • Relevant bindings include - sub :: Database sub (bound at T7786.hs:94:13) - k :: Sing k (bound at T7786.hs:94:11) - db :: Database inv (bound at T7786.hs:94:8) + sub :: Database sub (bound at T7786.hs:96:13) + k :: Sing k (bound at T7786.hs:96:11) + db :: Database inv (bound at T7786.hs:96:8) addSub :: Database inv -> Sing k -> Database sub -> Maybe (Database (BuriedUnder sub k inv)) - (bound at T7786.hs:94:1) + (bound at T7786.hs:96:1) -T7786.hs:95:31: error: +T7786.hs:97:31: error: • Could not deduce: Intersect (BuriedUnder sub k 'Empty) inv - ~ - 'Empty + ~ 'Empty arising from a use of ‘Sub’ from the context: xxx ~ 'Empty bound by a pattern with constructor: Nil :: forall a. Sing 'Empty, in a pattern binding in 'do' block - at T7786.hs:94:22-24 + at T7786.hs:96:22-24 • In the second argument of ‘($)’, namely ‘Sub db k sub’ In a stmt of a 'do' block: return $ Sub db k sub In the expression: do Nil :: Sing xxx <- foogle db k sub return $ Sub db k sub • Relevant bindings include - sub :: Database sub (bound at T7786.hs:94:13) - k :: Sing k (bound at T7786.hs:94:11) - db :: Database inv (bound at T7786.hs:94:8) + sub :: Database sub (bound at T7786.hs:96:13) + k :: Sing k (bound at T7786.hs:96:11) + db :: Database inv (bound at T7786.hs:96:8) addSub :: Database inv -> Sing k -> Database sub -> Maybe (Database (BuriedUnder sub k inv)) - (bound at T7786.hs:94:1) + (bound at T7786.hs:96:1) diff --git a/testsuite/tests/indexed-types/should_fail/T7967.hs b/testsuite/tests/indexed-types/should_fail/T7967.hs index 093f133563..ba828d60d0 100644 --- a/testsuite/tests/indexed-types/should_fail/T7967.hs +++ b/testsuite/tests/indexed-types/should_fail/T7967.hs @@ -1,21 +1,23 @@ {-# LANGUAGE TypeFamilies, DataKinds, TypeOperators, GADTs #-} module T7967 where +import Data.Kind (Type) + data Nat = Zero | Succ Nat -data SNat :: Nat -> * where +data SNat :: Nat -> Type where SZero :: SNat Zero SSucc :: SNat n -> SNat (Succ n) -data HList :: [*] -> * where +data HList :: [Type] -> Type where HNil :: HList '[] HCons :: h -> HList t -> HList (h ': t) -data Index :: Nat -> [*] -> * where +data Index :: Nat -> [Type] -> Type where IZero :: Index Zero (h ': t) ISucc :: Index n l -> Index (Succ n) (h ': l) -type family Lookup (n :: Nat) (l :: [*]) :: * +type family Lookup (n :: Nat) (l :: [Type]) :: Type type instance Lookup Zero (h ': t) = h type instance Lookup (Succ n) (h ': t) = Lookup n t diff --git a/testsuite/tests/indexed-types/should_fail/T7967.stderr b/testsuite/tests/indexed-types/should_fail/T7967.stderr index 44fb064594..63d2ba8328 100644 --- a/testsuite/tests/indexed-types/should_fail/T7967.stderr +++ b/testsuite/tests/indexed-types/should_fail/T7967.stderr @@ -1,7 +1,7 @@ -T7967.hs:31:26: - Couldn't match type ‘h0 : t0’ with ‘'[]’ - Expected type: Index n l - Actual type: Index 'Zero (h0 : t0) - In the expression: IZero - In an equation for ‘sNatToIndex’: sNatToIndex SZero HNil = IZero +T7967.hs:33:26: error: + • Couldn't match type ‘h0 : t0’ with ‘'[]’ + Expected type: Index n l + Actual type: Index 'Zero (h0 : t0) + • In the expression: IZero + In an equation for ‘sNatToIndex’: sNatToIndex SZero HNil = IZero diff --git a/testsuite/tests/indexed-types/should_fail/T9036.hs b/testsuite/tests/indexed-types/should_fail/T9036.hs index 550adb4b0a..54af6f6714 100644 --- a/testsuite/tests/indexed-types/should_fail/T9036.hs +++ b/testsuite/tests/indexed-types/should_fail/T9036.hs @@ -2,14 +2,15 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeFamilies #-} - module T9036 where +import Data.Kind + class UncurryM t where - type GetMonad t :: * -> * + type GetMonad t :: Type -> Type class Curry a b where - type Curried a b :: * + type Curried a b :: Type gSimple :: String -> String -> [String] gSimple = simpleLogger (return ()) diff --git a/testsuite/tests/indexed-types/should_fail/T9036.stderr b/testsuite/tests/indexed-types/should_fail/T9036.stderr index 6f2c162f1a..151dfb7f2d 100644 --- a/testsuite/tests/indexed-types/should_fail/T9036.stderr +++ b/testsuite/tests/indexed-types/should_fail/T9036.stderr @@ -1,5 +1,5 @@ -T9036.hs:17:17: error: +T9036.hs:18:17: error: • Couldn't match type ‘Curried t0 [t0]’ with ‘Curried t [t]’ Expected type: Maybe (GetMonad t after) -> Curried t [t] Actual type: Maybe (GetMonad t0 after) -> Curried t0 [t0] diff --git a/testsuite/tests/indexed-types/should_fail/T9662.hs b/testsuite/tests/indexed-types/should_fail/T9662.hs index 2972eca22f..8563c90403 100644 --- a/testsuite/tests/indexed-types/should_fail/T9662.hs +++ b/testsuite/tests/indexed-types/should_fail/T9662.hs @@ -4,10 +4,12 @@ module T9662 where +import Data.Kind (Type) + data Exp a = Exp data (a:.b) = a:.b -type family Plain e :: * +type family Plain e :: Type type instance Plain (Exp a) = a type instance Plain (a:.b) = Plain a :. Plain b diff --git a/testsuite/tests/indexed-types/should_fail/T9662.stderr b/testsuite/tests/indexed-types/should_fail/T9662.stderr index 54b05665a3..4f35d92b5e 100644 --- a/testsuite/tests/indexed-types/should_fail/T9662.stderr +++ b/testsuite/tests/indexed-types/should_fail/T9662.stderr @@ -1,11 +1,11 @@ -T9662.hs:47:8: error: +T9662.hs:49:8: error: • Couldn't match type ‘k’ with ‘Int’ ‘k’ is a rigid type variable bound by the type signature for: test :: forall sh k m n. Shape (((sh :. k) :. m) :. n) -> Shape (((sh :. m) :. n) :. k) - at T9662.hs:44:1-50 + at T9662.hs:46:1-50 Expected type: Exp (((sh :. m) :. n) :. k) -> Exp (((sh :. m) :. n) :. k) Actual type: Exp @@ -32,4 +32,4 @@ T9662.hs:47:8: error: • Relevant bindings include test :: Shape (((sh :. k) :. m) :. n) -> Shape (((sh :. m) :. n) :. k) - (bound at T9662.hs:45:1) + (bound at T9662.hs:47:1) diff --git a/testsuite/tests/indexed-types/should_run/T11465a.hs b/testsuite/tests/indexed-types/should_run/T11465a.hs index d3626cf198..93d72545e3 100644 --- a/testsuite/tests/indexed-types/should_run/T11465a.hs +++ b/testsuite/tests/indexed-types/should_run/T11465a.hs @@ -2,7 +2,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE TypeInType #-} import GHC.Exts import GHC.Types diff --git a/testsuite/tests/overloadedrecflds/should_run/overloadedrecflds_generics.hs b/testsuite/tests/overloadedrecflds/should_run/overloadedrecflds_generics.hs index c2b4bd6120..56f93fb7af 100644 --- a/testsuite/tests/overloadedrecflds/should_run/overloadedrecflds_generics.hs +++ b/testsuite/tests/overloadedrecflds/should_run/overloadedrecflds_generics.hs @@ -17,14 +17,15 @@ import GHC.Generics import Data.Data import Data.Proxy +import Data.Kind -type family FirstSelector (f :: * -> *) :: Meta +type family FirstSelector (f :: Type -> Type) :: Meta type instance FirstSelector (M1 D x f) = FirstSelector f type instance FirstSelector (M1 C x f) = FirstSelector f type instance FirstSelector (a :*: b) = FirstSelector a type instance FirstSelector (M1 S s f) = s -data SelectorProxy (s :: Meta) (f :: * -> *) a = SelectorProxy +data SelectorProxy (s :: Meta) (f :: Type -> Type) a = SelectorProxy type SelectorProxy' (s :: Meta) = SelectorProxy s Proxy () -- Extract the first selector name using GHC.Generics diff --git a/testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun07.hs b/testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun07.hs index c492ac87a1..fdd81c213d 100644 --- a/testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun07.hs +++ b/testsuite/tests/overloadedrecflds/should_run/overloadedrecfldsrun07.hs @@ -1,10 +1,10 @@ {-# LANGUAGE DataKinds + , PolyKinds , FlexibleContexts , FlexibleInstances , GADTs , MultiParamTypeClasses , OverloadedLabels - , TypeInType , ScopedTypeVariables , TypeApplications , TypeOperators @@ -13,13 +13,13 @@ import GHC.OverloadedLabels import GHC.Records -import GHC.TypeLits hiding (type (*)) +import GHC.TypeLits import Data.Kind data Label (x :: Symbol) = Label data Labelled x a = Label x := a -data Rec :: forall k. [(k, *)] -> * where +data Rec :: forall k. [(k, Type)] -> Type where Nil :: Rec '[] (:>) :: Labelled x a -> Rec xs -> Rec ('(x, a) ': xs) infixr 5 :> diff --git a/testsuite/tests/parser/should_compile/DumpParsedAst.stderr b/testsuite/tests/parser/should_compile/DumpParsedAst.stderr index ea9becb6c5..a1765035fb 100644 --- a/testsuite/tests/parser/should_compile/DumpParsedAst.stderr +++ b/testsuite/tests/parser/should_compile/DumpParsedAst.stderr @@ -80,77 +80,56 @@ (HsParTy (NoExt) ({ DumpParsedAst.hs:8:11-16 } - (HsAppsTy + (HsOpTy (NoExt) - [({ DumpParsedAst.hs:8:11 } - (HsAppPrefix - (NoExt) - ({ DumpParsedAst.hs:8:11 } - (HsTyVar - (NoExt) - (NotPromoted) - ({ DumpParsedAst.hs:8:11 } - (Unqual - {OccName: a})))))) - ,({ DumpParsedAst.hs:8:13 } - (HsAppInfix - (NoExt) - ({ DumpParsedAst.hs:8:13 } - (Exact - {Name: :})))) - ,({ DumpParsedAst.hs:8:15-16 } - (HsAppPrefix - (NoExt) - ({ DumpParsedAst.hs:8:15-16 } - (HsTyVar - (NoExt) - (NotPromoted) - ({ DumpParsedAst.hs:8:15-16 } - (Unqual - {OccName: as}))))))]))))] - (Prefix) - ({ DumpParsedAst.hs:8:21-36 } - (HsAppsTy - (NoExt) - [({ DumpParsedAst.hs:8:21-24 } - (HsAppPrefix - (NoExt) - ({ DumpParsedAst.hs:8:21-24 } + ({ DumpParsedAst.hs:8:11 } (HsTyVar (NoExt) (NotPromoted) - ({ DumpParsedAst.hs:8:21-24 } + ({ DumpParsedAst.hs:8:11 } (Unqual - {OccName: Succ})))))) - ,({ DumpParsedAst.hs:8:26-36 } - (HsAppPrefix - (NoExt) - ({ DumpParsedAst.hs:8:26-36 } - (HsParTy + {OccName: a})))) + ({ DumpParsedAst.hs:8:13 } + (Exact + {Name: :})) + ({ DumpParsedAst.hs:8:15-16 } + (HsTyVar (NoExt) - ({ DumpParsedAst.hs:8:27-35 } - (HsAppsTy - (NoExt) - [({ DumpParsedAst.hs:8:27-32 } - (HsAppPrefix - (NoExt) - ({ DumpParsedAst.hs:8:27-32 } - (HsTyVar - (NoExt) - (NotPromoted) - ({ DumpParsedAst.hs:8:27-32 } - (Unqual - {OccName: Length})))))) - ,({ DumpParsedAst.hs:8:34-35 } - (HsAppPrefix - (NoExt) - ({ DumpParsedAst.hs:8:34-35 } - (HsTyVar - (NoExt) - (NotPromoted) - ({ DumpParsedAst.hs:8:34-35 } - (Unqual - {OccName: as}))))))]))))))]))))) + (NotPromoted) + ({ DumpParsedAst.hs:8:15-16 } + (Unqual + {OccName: as}))))))))] + (Prefix) + ({ DumpParsedAst.hs:8:21-36 } + (HsAppTy + (NoExt) + ({ DumpParsedAst.hs:8:21-24 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:8:21-24 } + (Unqual + {OccName: Succ})))) + ({ DumpParsedAst.hs:8:26-36 } + (HsParTy + (NoExt) + ({ DumpParsedAst.hs:8:27-35 } + (HsAppTy + (NoExt) + ({ DumpParsedAst.hs:8:27-32 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:8:27-32 } + (Unqual + {OccName: Length})))) + ({ DumpParsedAst.hs:8:34-35 } + (HsTyVar + (NoExt) + (NotPromoted) + ({ DumpParsedAst.hs:8:34-35 } + (Unqual + {OccName: as}))))))))))))) ,({ DumpParsedAst.hs:9:3-24 } (HsIB (NoExt) diff --git a/testsuite/tests/parser/should_compile/DumpRenamedAst.hs b/testsuite/tests/parser/should_compile/DumpRenamedAst.hs index 493b736df5..bf3e372461 100644 --- a/testsuite/tests/parser/should_compile/DumpRenamedAst.hs +++ b/testsuite/tests/parser/should_compile/DumpRenamedAst.hs @@ -1,5 +1,5 @@ {-# LANGUAGE DataKinds, GADTs, PolyKinds, RankNTypes, TypeOperators, - TypeFamilies #-} + TypeFamilies, StarIsType #-} module DumpRenamedAst where diff --git a/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr b/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr index 4ca996fde0..673b391d7f 100644 --- a/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr +++ b/testsuite/tests/parser/should_compile/DumpRenamedAst.stderr @@ -69,10 +69,10 @@ {Name: DumpRenamedAst.Peano}) (HsQTvs (HsQTvsRn - [] - {NameSet: - []}) - []) + [] + {NameSet: + []}) + []) (Prefix) (HsDataDefn (NoExt) @@ -124,8 +124,8 @@ [({ DumpRenamedAst.hs:9:3-36 } (HsIB (HsIBRn - [{Name: a} - ,{Name: as}] + [{Name: a} + ,{Name: as}] (True)) (FamEqn (NoExt) @@ -182,7 +182,7 @@ ,({ DumpRenamedAst.hs:10:3-24 } (HsIB (HsIBRn - [] + [] (True)) (FamEqn (NoExt) @@ -204,7 +204,7 @@ {Name: DumpRenamedAst.Length}) (HsQTvs (HsQTvsRn - [{Name: k}] + [{Name: k}] {NameSet: []}) [({ DumpRenamedAst.hs:8:20-30 } @@ -246,10 +246,10 @@ {Name: DumpRenamedAst.Nat}) (HsQTvs (HsQTvsRn - [{Name: k}] - {NameSet: - []}) - []) + [{Name: k}] + {NameSet: + []}) + []) (Prefix) ({ DumpRenamedAst.hs:12:17-30 } (KindSig @@ -273,11 +273,9 @@ ({ DumpRenamedAst.hs:12:25 } {Name: k}))) ({ DumpRenamedAst.hs:12:30 } - (HsTyVar + (HsStarTy (NoExt) - (NotPromoted) - ({ DumpRenamedAst.hs:12:30 } - {Name: GHC.Types.*}))))))))) + (False))))))))) (Nothing))))] [] [({ DumpRenamedAst.hs:(15,1)-(16,45) } @@ -286,8 +284,8 @@ (DataFamInstDecl (HsIB (HsIBRn - [{Name: k} - ,{Name: a}] + [{Name: k} + ,{Name: a}] (True)) (FamEqn (NoExt) @@ -312,11 +310,9 @@ ({ DumpRenamedAst.hs:15:28 } {Name: k}))) ({ DumpRenamedAst.hs:15:33 } - (HsTyVar + (HsStarTy (NoExt) - (NotPromoted) - ({ DumpRenamedAst.hs:15:33 } - {Name: GHC.Types.*})))))))] + (False)))))))] (Prefix) (HsDataDefn (NoExt) @@ -341,17 +337,13 @@ ({ DumpRenamedAst.hs:15:40 } {Name: k}))) ({ DumpRenamedAst.hs:15:45 } - (HsTyVar + (HsStarTy (NoExt) - (NotPromoted) - ({ DumpRenamedAst.hs:15:45 } - {Name: GHC.Types.*}))))))) + (False))))))) ({ DumpRenamedAst.hs:15:51 } - (HsTyVar + (HsStarTy (NoExt) - (NotPromoted) - ({ DumpRenamedAst.hs:15:51 } - {Name: GHC.Types.*})))))) + (False)))))) [({ DumpRenamedAst.hs:16:3-45 } (ConDeclGADT (NoExt) @@ -360,11 +352,11 @@ (False) (HsQTvs (HsQTvsRn - [{Name: f} - ,{Name: g}] - {NameSet: - []}) - []) + [{Name: f} + ,{Name: g}] + {NameSet: + []}) + []) (Nothing) (PrefixCon [({ DumpRenamedAst.hs:16:10-34 } diff --git a/testsuite/tests/parser/should_compile/T10379.hs b/testsuite/tests/parser/should_compile/T10379.hs index 1eb5f96382..eb231c4415 100644 --- a/testsuite/tests/parser/should_compile/T10379.hs +++ b/testsuite/tests/parser/should_compile/T10379.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE KindSignatures, GADTs, DataKinds, TypeOperators #-} +{-# LANGUAGE KindSignatures, GADTs, DataKinds #-} module Foo where data Foo1 :: [*] -> * where diff --git a/testsuite/tests/parser/should_fail/T15209.stderr b/testsuite/tests/parser/should_fail/T15209.stderr index f5418fab74..9d1e151cf2 100644 --- a/testsuite/tests/parser/should_fail/T15209.stderr +++ b/testsuite/tests/parser/should_fail/T15209.stderr @@ -1,2 +1,2 @@ -T15209.hs:6:8: error: Not in scope: type constructor or class ‘~#’ +T15209.hs:6:10: error: Not in scope: type constructor or class ‘~#’ diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T index 9fcc3ba97d..1e71e40420 100644 --- a/testsuite/tests/parser/should_fail/all.T +++ b/testsuite/tests/parser/should_fail/all.T @@ -120,3 +120,8 @@ test('NumericUnderscoresFail1', grep_errmsg(r'^NumericUnderscoresFail1.hs:'), compile_fail, ['']) test('InfixAppPatErr', normal, compile_fail, ['']) + +test('typeops_A', normal, compile_fail, ['']) +test('typeops_B', normal, compile_fail, ['']) +test('typeops_C', normal, compile_fail, ['']) +test('typeops_D', normal, compile_fail, ['']) diff --git a/testsuite/tests/parser/should_fail/readFail036.hs b/testsuite/tests/parser/should_fail/readFail036.hs index 2bb23149dd..15afd980f8 100644 --- a/testsuite/tests/parser/should_fail/readFail036.hs +++ b/testsuite/tests/parser/should_fail/readFail036.hs @@ -1,5 +1,5 @@ - module Foo where -data Foo (a :: *) = Foo a +import Data.Kind (Type) +data Foo (a :: Type) = Foo a diff --git a/testsuite/tests/parser/should_fail/readFail036.stderr b/testsuite/tests/parser/should_fail/readFail036.stderr index 0d22eb8363..a66afacacf 100644 --- a/testsuite/tests/parser/should_fail/readFail036.stderr +++ b/testsuite/tests/parser/should_fail/readFail036.stderr @@ -1,5 +1,5 @@ -readFail036.hs:4:16: - Illegal kind signature: ‘*’ +readFail036.hs:5:16: error: + Illegal kind signature: ‘Type’ Perhaps you intended to use KindSignatures In the data type declaration for ‘Foo’ diff --git a/testsuite/tests/parser/should_fail/typeops_A.hs b/testsuite/tests/parser/should_fail/typeops_A.hs new file mode 100644 index 0000000000..abd7f528c6 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_A.hs @@ -0,0 +1 @@ +type X = 1 + diff --git a/testsuite/tests/parser/should_fail/typeops_A.stderr b/testsuite/tests/parser/should_fail/typeops_A.stderr new file mode 100644 index 0000000000..69f7aac6be --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_A.stderr @@ -0,0 +1,2 @@ + +typeops_A.hs:1:12: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/parser/should_fail/typeops_B.hs b/testsuite/tests/parser/should_fail/typeops_B.hs new file mode 100644 index 0000000000..ac65f872de --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_B.hs @@ -0,0 +1 @@ +type X = + 1 diff --git a/testsuite/tests/parser/should_fail/typeops_B.stderr b/testsuite/tests/parser/should_fail/typeops_B.stderr new file mode 100644 index 0000000000..030516a27f --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_B.stderr @@ -0,0 +1,2 @@ + +typeops_B.hs:1:10: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/parser/should_fail/typeops_C.hs b/testsuite/tests/parser/should_fail/typeops_C.hs new file mode 100644 index 0000000000..e55838934a --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_C.hs @@ -0,0 +1 @@ +type X = 1 + + 2 diff --git a/testsuite/tests/parser/should_fail/typeops_C.stderr b/testsuite/tests/parser/should_fail/typeops_C.stderr new file mode 100644 index 0000000000..280323bb67 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_C.stderr @@ -0,0 +1,2 @@ + +typeops_C.hs:1:12: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/parser/should_fail/typeops_D.hs b/testsuite/tests/parser/should_fail/typeops_D.hs new file mode 100644 index 0000000000..655b2f15f0 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_D.hs @@ -0,0 +1 @@ +type X = + diff --git a/testsuite/tests/parser/should_fail/typeops_D.stderr b/testsuite/tests/parser/should_fail/typeops_D.stderr new file mode 100644 index 0000000000..0ce7e29559 --- /dev/null +++ b/testsuite/tests/parser/should_fail/typeops_D.stderr @@ -0,0 +1,2 @@ + +typeops_D.hs:1:10: error: Operator applied to too few arguments: + diff --git a/testsuite/tests/partial-sigs/should_compile/T15039a.hs b/testsuite/tests/partial-sigs/should_compile/T15039a.hs index 7f32cb8488..3430f14bb9 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039a.hs +++ b/testsuite/tests/partial-sigs/should_compile/T15039a.hs @@ -2,7 +2,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fdefer-type-errors #-} module T15039a where @@ -15,13 +15,13 @@ import Data.Type.Equality data Dict :: Constraint -> Type where Dict :: c => Dict c -ex1 :: Dict ((a :: *) ~ (b :: *)) -> () +ex1 :: Dict ((a :: Type) ~ (b :: Type)) -> () ex1 (Dict :: _) = () -ex2 :: Dict ((a :: *) ~~ (b :: *)) -> () +ex2 :: Dict ((a :: Type) ~~ (b :: Type)) -> () ex2 (Dict :: _) = () -ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () +ex3 :: Dict ((a :: Type) ~~ (b :: k)) -> () ex3 (Dict :: _) = () -- Don't know how to make GHC print an unlifted, nominal equality in an error @@ -29,10 +29,10 @@ ex3 (Dict :: _) = () -- -- ex4, ex5 :: ??? -ex6 :: Dict (Coercible (a :: *) (b :: *)) -> () +ex6 :: Dict (Coercible (a :: Type) (b :: Type)) -> () ex6 (Dict :: _) = () -ex7 :: _ => Coercion (a :: *) (b :: *) +ex7 :: _ => Coercion (a :: Type) (b :: Type) ex7 = Coercion -- Don't know how to make GHC print an unlifted, heterogeneous, diff --git a/testsuite/tests/partial-sigs/should_compile/T15039a.stderr b/testsuite/tests/partial-sigs/should_compile/T15039a.stderr index c45e82e5ef..d9c8e1056f 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039a.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039a.stderr @@ -4,7 +4,7 @@ T15039a.hs:19:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: ex1 :: forall a b. Dict (a ~ b) -> () - at T15039a.hs:18:1-39 + at T15039a.hs:18:1-45 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex1’: ex1 (Dict :: _) = () @@ -16,7 +16,7 @@ T15039a.hs:22:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: ex2 :: forall a b. Dict (a ~ b) -> () - at T15039a.hs:21:1-40 + at T15039a.hs:21:1-46 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex2’: ex2 (Dict :: _) = () @@ -28,7 +28,7 @@ T15039a.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’, ‘k’ are rigid type variables bound by the type signature for: ex3 :: forall k a (b :: k). Dict (a ~~ b) -> () - at T15039a.hs:24:1-40 + at T15039a.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex3’: ex3 (Dict :: _) = () @@ -40,7 +40,7 @@ T15039a.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: ex6 :: forall a b. Dict (Coercible a b) -> () - at T15039a.hs:32:1-47 + at T15039a.hs:32:1-53 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex6’: ex6 (Dict :: _) = () @@ -52,4 +52,5 @@ T15039a.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: Coercible a b => Coercion a b at T15039a.hs:36:1-14 - • In the type signature: ex7 :: _ => Coercion (a :: *) (b :: *) + • In the type signature: + ex7 :: _ => Coercion (a :: Type) (b :: Type) diff --git a/testsuite/tests/partial-sigs/should_compile/T15039b.hs b/testsuite/tests/partial-sigs/should_compile/T15039b.hs index 4966059912..5069e04655 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039b.hs +++ b/testsuite/tests/partial-sigs/should_compile/T15039b.hs @@ -2,7 +2,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fdefer-type-errors #-} module T15039b where @@ -15,13 +15,13 @@ import Data.Type.Equality data Dict :: Constraint -> Type where Dict :: c => Dict c -ex1 :: Dict ((a :: *) ~ (b :: *)) -> () +ex1 :: Dict ((a :: Type) ~ (b :: Type)) -> () ex1 (Dict :: _) = () -ex2 :: Dict ((a :: *) ~~ (b :: *)) -> () +ex2 :: Dict ((a :: Type) ~~ (b :: Type)) -> () ex2 (Dict :: _) = () -ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () +ex3 :: Dict ((a :: Type) ~~ (b :: k)) -> () ex3 (Dict :: _) = () -- Don't know how to make GHC print an unlifted, nominal equality in an error @@ -29,10 +29,10 @@ ex3 (Dict :: _) = () -- -- ex4, ex5 :: ??? -ex6 :: Dict (Coercible (a :: *) (b :: *)) -> () +ex6 :: Dict (Coercible (a :: Type) (b :: Type)) -> () ex6 (Dict :: _) = () -ex7 :: _ => Coercion (a :: *) (b :: *) +ex7 :: _ => Coercion (a :: Type) (b :: Type) ex7 = Coercion -- Don't know how to make GHC print an unlifted, heterogeneous, diff --git a/testsuite/tests/partial-sigs/should_compile/T15039b.stderr b/testsuite/tests/partial-sigs/should_compile/T15039b.stderr index dffde1c8f1..020c253516 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039b.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039b.stderr @@ -1,56 +1,62 @@ T15039b.hs:19:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Dict ((a :: *) ~ (b :: *))’ + • Found type wildcard ‘_’ + standing for ‘Dict ((a :: Type) ~ (b :: Type))’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex1 :: forall a b. Dict ((a :: *) ~ (b :: *)) -> () - at T15039b.hs:18:1-39 + ex1 :: forall a b. Dict ((a :: Type) ~ (b :: Type)) -> () + at T15039b.hs:18:1-45 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex1’: ex1 (Dict :: _) = () • Relevant bindings include - ex1 :: Dict ((a :: *) ~ (b :: *)) -> () (bound at T15039b.hs:19:1) + ex1 :: Dict ((a :: Type) ~ (b :: Type)) -> () + (bound at T15039b.hs:19:1) T15039b.hs:22:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Dict ((a :: *) ~ (b :: *))’ + • Found type wildcard ‘_’ + standing for ‘Dict ((a :: Type) ~ (b :: Type))’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex2 :: forall a b. Dict ((a :: *) ~ (b :: *)) -> () - at T15039b.hs:21:1-40 + ex2 :: forall a b. Dict ((a :: Type) ~ (b :: Type)) -> () + at T15039b.hs:21:1-46 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex2’: ex2 (Dict :: _) = () • Relevant bindings include - ex2 :: Dict ((a :: *) ~ (b :: *)) -> () (bound at T15039b.hs:22:1) + ex2 :: Dict ((a :: Type) ~ (b :: Type)) -> () + (bound at T15039b.hs:22:1) T15039b.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ - standing for ‘Dict ((a :: *) ~~ (b :: k))’ + standing for ‘Dict ((a :: Type) ~~ (b :: k))’ Where: ‘a’, ‘b’, ‘k’ are rigid type variables bound by the type signature for: - ex3 :: forall k a (b :: k). Dict ((a :: *) ~~ (b :: k)) -> () - at T15039b.hs:24:1-40 + ex3 :: forall k a (b :: k). Dict ((a :: Type) ~~ (b :: k)) -> () + at T15039b.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex3’: ex3 (Dict :: _) = () • Relevant bindings include - ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () (bound at T15039b.hs:25:1) + ex3 :: Dict ((a :: Type) ~~ (b :: k)) -> () + (bound at T15039b.hs:25:1) T15039b.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Dict (Coercible * a b)’ + • Found type wildcard ‘_’ standing for ‘Dict (Coercible Type a b)’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex6 :: forall a b. Dict (Coercible * a b) -> () - at T15039b.hs:32:1-47 + ex6 :: forall a b. Dict (Coercible Type a b) -> () + at T15039b.hs:32:1-53 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex6’: ex6 (Dict :: _) = () • Relevant bindings include - ex6 :: Dict (Coercible * a b) -> () (bound at T15039b.hs:33:1) + ex6 :: Dict (Coercible Type a b) -> () (bound at T15039b.hs:33:1) T15039b.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Coercible * a b’ + • Found type wildcard ‘_’ standing for ‘Coercible Type a b’ Where: ‘a’, ‘b’ are rigid type variables bound by - the inferred type of ex7 :: Coercible * a b => Coercion * a b + the inferred type of ex7 :: Coercible Type a b => Coercion Type a b at T15039b.hs:36:1-14 - • In the type signature: ex7 :: _ => Coercion (a :: *) (b :: *) + • In the type signature: + ex7 :: _ => Coercion (a :: Type) (b :: Type) diff --git a/testsuite/tests/partial-sigs/should_compile/T15039c.hs b/testsuite/tests/partial-sigs/should_compile/T15039c.hs index aa54c4e919..062404766f 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039c.hs +++ b/testsuite/tests/partial-sigs/should_compile/T15039c.hs @@ -2,7 +2,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fdefer-type-errors #-} module T15039c where @@ -15,13 +15,13 @@ import Data.Type.Equality data Dict :: Constraint -> Type where Dict :: c => Dict c -ex1 :: Dict ((a :: *) ~ (b :: *)) -> () +ex1 :: Dict ((a :: Type) ~ (b :: Type)) -> () ex1 (Dict :: _) = () -ex2 :: Dict ((a :: *) ~~ (b :: *)) -> () +ex2 :: Dict ((a :: Type) ~~ (b :: Type)) -> () ex2 (Dict :: _) = () -ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () +ex3 :: Dict ((a :: Type) ~~ (b :: k)) -> () ex3 (Dict :: _) = () -- Don't know how to make GHC print an unlifted, nominal equality in an error @@ -29,10 +29,10 @@ ex3 (Dict :: _) = () -- -- ex4, ex5 :: ??? -ex6 :: Dict (Coercible (a :: *) (b :: *)) -> () +ex6 :: Dict (Coercible (a :: Type) (b :: Type)) -> () ex6 (Dict :: _) = () -ex7 :: _ => Coercion (a :: *) (b :: *) +ex7 :: _ => Coercion (a :: Type) (b :: Type) ex7 = Coercion -- Don't know how to make GHC print an unlifted, heterogeneous, diff --git a/testsuite/tests/partial-sigs/should_compile/T15039c.stderr b/testsuite/tests/partial-sigs/should_compile/T15039c.stderr index bf3aff1081..29989c2cdc 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039c.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039c.stderr @@ -4,7 +4,7 @@ T15039c.hs:19:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: ex1 :: forall a b. Dict (a ~ b) -> () - at T15039c.hs:18:1-39 + at T15039c.hs:18:1-45 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex1’: ex1 (Dict :: _) = () @@ -16,7 +16,7 @@ T15039c.hs:22:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: ex2 :: forall a b. Dict (a ~~ b) -> () - at T15039c.hs:21:1-40 + at T15039c.hs:21:1-46 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex2’: ex2 (Dict :: _) = () @@ -28,7 +28,7 @@ T15039c.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’, ‘k’ are rigid type variables bound by the type signature for: ex3 :: forall k a (b :: k). Dict (a ~~ b) -> () - at T15039c.hs:24:1-40 + at T15039c.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex3’: ex3 (Dict :: _) = () @@ -40,7 +40,7 @@ T15039c.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: ex6 :: forall a b. Dict (Coercible a b) -> () - at T15039c.hs:32:1-47 + at T15039c.hs:32:1-53 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex6’: ex6 (Dict :: _) = () @@ -52,4 +52,5 @@ T15039c.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of ex7 :: (a ~R# b) => Coercion a b at T15039c.hs:36:1-14 - • In the type signature: ex7 :: _ => Coercion (a :: *) (b :: *) + • In the type signature: + ex7 :: _ => Coercion (a :: Type) (b :: Type) diff --git a/testsuite/tests/partial-sigs/should_compile/T15039d.hs b/testsuite/tests/partial-sigs/should_compile/T15039d.hs index 3b5a5a27c3..7a87244f99 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039d.hs +++ b/testsuite/tests/partial-sigs/should_compile/T15039d.hs @@ -2,7 +2,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fdefer-type-errors #-} module T15039d where @@ -15,13 +15,13 @@ import Data.Type.Equality data Dict :: Constraint -> Type where Dict :: c => Dict c -ex1 :: Dict ((a :: *) ~ (b :: *)) -> () +ex1 :: Dict ((a :: Type) ~ (b :: Type)) -> () ex1 (Dict :: _) = () -ex2 :: Dict ((a :: *) ~~ (b :: *)) -> () +ex2 :: Dict ((a :: Type) ~~ (b :: Type)) -> () ex2 (Dict :: _) = () -ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () +ex3 :: Dict ((a :: Type) ~~ (b :: k)) -> () ex3 (Dict :: _) = () -- Don't know how to make GHC print an unlifted, nominal equality in an error @@ -29,10 +29,10 @@ ex3 (Dict :: _) = () -- -- ex4, ex5 :: ??? -ex6 :: Dict (Coercible (a :: *) (b :: *)) -> () +ex6 :: Dict (Coercible (a :: Type) (b :: Type)) -> () ex6 (Dict :: _) = () -ex7 :: _ => Coercion (a :: *) (b :: *) +ex7 :: _ => Coercion (a :: Type) (b :: Type) ex7 = Coercion -- Don't know how to make GHC print an unlifted, heterogeneous, diff --git a/testsuite/tests/partial-sigs/should_compile/T15039d.stderr b/testsuite/tests/partial-sigs/should_compile/T15039d.stderr index 8595955f87..6c6e1a0c24 100644 --- a/testsuite/tests/partial-sigs/should_compile/T15039d.stderr +++ b/testsuite/tests/partial-sigs/should_compile/T15039d.stderr @@ -1,58 +1,64 @@ T15039d.hs:19:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Dict ((a :: *) ~ (b :: *))’ + • Found type wildcard ‘_’ + standing for ‘Dict ((a :: Type) ~ (b :: Type))’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex1 :: forall a b. Dict ((a :: *) ~ (b :: *)) -> () - at T15039d.hs:18:1-39 + ex1 :: forall a b. Dict ((a :: Type) ~ (b :: Type)) -> () + at T15039d.hs:18:1-45 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex1’: ex1 (Dict :: _) = () • Relevant bindings include - ex1 :: Dict ((a :: *) ~ (b :: *)) -> () (bound at T15039d.hs:19:1) + ex1 :: Dict ((a :: Type) ~ (b :: Type)) -> () + (bound at T15039d.hs:19:1) T15039d.hs:22:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ - standing for ‘Dict ((a :: *) ~~ (b :: *))’ + standing for ‘Dict ((a :: Type) ~~ (b :: Type))’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex2 :: forall a b. Dict ((a :: *) ~~ (b :: *)) -> () - at T15039d.hs:21:1-40 + ex2 :: forall a b. Dict ((a :: Type) ~~ (b :: Type)) -> () + at T15039d.hs:21:1-46 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex2’: ex2 (Dict :: _) = () • Relevant bindings include - ex2 :: Dict ((a :: *) ~~ (b :: *)) -> () (bound at T15039d.hs:22:1) + ex2 :: Dict ((a :: Type) ~~ (b :: Type)) -> () + (bound at T15039d.hs:22:1) T15039d.hs:25:14: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ - standing for ‘Dict ((a :: *) ~~ (b :: k))’ + standing for ‘Dict ((a :: Type) ~~ (b :: k))’ Where: ‘a’, ‘b’, ‘k’ are rigid type variables bound by the type signature for: - ex3 :: forall k a (b :: k). Dict ((a :: *) ~~ (b :: k)) -> () - at T15039d.hs:24:1-40 + ex3 :: forall k a (b :: k). Dict ((a :: Type) ~~ (b :: k)) -> () + at T15039d.hs:24:1-43 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex3’: ex3 (Dict :: _) = () • Relevant bindings include - ex3 :: Dict ((a :: *) ~~ (b :: k)) -> () (bound at T15039d.hs:25:1) + ex3 :: Dict ((a :: Type) ~~ (b :: k)) -> () + (bound at T15039d.hs:25:1) T15039d.hs:33:14: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘Dict (Coercible * a b)’ + • Found type wildcard ‘_’ standing for ‘Dict (Coercible Type a b)’ Where: ‘a’, ‘b’ are rigid type variables bound by the type signature for: - ex6 :: forall a b. Dict (Coercible * a b) -> () - at T15039d.hs:32:1-47 + ex6 :: forall a b. Dict (Coercible Type a b) -> () + at T15039d.hs:32:1-53 • In a pattern type signature: _ In the pattern: Dict :: _ In an equation for ‘ex6’: ex6 (Dict :: _) = () • Relevant bindings include - ex6 :: Dict (Coercible * a b) -> () (bound at T15039d.hs:33:1) + ex6 :: Dict (Coercible Type a b) -> () (bound at T15039d.hs:33:1) T15039d.hs:35:8: warning: [-Wpartial-type-signatures (in -Wdefault)] - • Found type wildcard ‘_’ standing for ‘(a :: *) ~R# (b :: *)’ + • Found type wildcard ‘_’ + standing for ‘(a :: Type) ~R# (b :: Type)’ Where: ‘a’, ‘b’ are rigid type variables bound by the inferred type of - ex7 :: ((a :: *) ~R# (b :: *)) => Coercion * a b + ex7 :: ((a :: Type) ~R# (b :: Type)) => Coercion Type a b at T15039d.hs:36:1-14 - • In the type signature: ex7 :: _ => Coercion (a :: *) (b :: *) + • In the type signature: + ex7 :: _ => Coercion (a :: Type) (b :: Type) diff --git a/testsuite/tests/partial-sigs/should_fail/T14040a.hs b/testsuite/tests/partial-sigs/should_fail/T14040a.hs index 382e21823c..2985339f49 100644 --- a/testsuite/tests/partial-sigs/should_fail/T14040a.hs +++ b/testsuite/tests/partial-sigs/should_fail/T14040a.hs @@ -3,7 +3,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T14040a where import Data.Kind diff --git a/testsuite/tests/partial-sigs/should_fail/T14584.hs b/testsuite/tests/partial-sigs/should_fail/T14584.hs index 508725eec7..1615b26205 100644 --- a/testsuite/tests/partial-sigs/should_fail/T14584.hs +++ b/testsuite/tests/partial-sigs/should_fail/T14584.hs @@ -17,10 +17,10 @@ {-# Language FunctionalDependencies #-} {-# Language UndecidableSuperClasses #-} {-# Language UndecidableInstances #-} -{-# Language TypeInType #-} {-# Language AllowAmbiguousTypes #-} {-# Language InstanceSigs, TypeApplications #-} + module T14584 where import Data.Monoid diff --git a/testsuite/tests/partial-sigs/should_fail/T14584.stderr b/testsuite/tests/partial-sigs/should_fail/T14584.stderr index b7531aa2ce..c53c822ba3 100644 --- a/testsuite/tests/partial-sigs/should_fail/T14584.stderr +++ b/testsuite/tests/partial-sigs/should_fail/T14584.stderr @@ -11,7 +11,7 @@ T14584.hs:56:41: warning: [-Wdeferred-type-errors (in -Wdefault)] act @_ @_ @act (fromSing @m (sing @m @a :: Sing _)) T14584.hs:56:50: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Expected kind ‘m1’, but ‘a’ has kind ‘*’ + • Expected kind ‘m1’, but ‘a’ has kind ‘Type’ • In the type ‘a’ In the second argument of ‘fromSing’, namely ‘(sing @m @a :: Sing _)’ diff --git a/testsuite/tests/patsyn/should_compile/T12698.hs b/testsuite/tests/patsyn/should_compile/T12698.hs index 27d54d8eba..68cd817677 100644 --- a/testsuite/tests/patsyn/should_compile/T12698.hs +++ b/testsuite/tests/patsyn/should_compile/T12698.hs @@ -1,5 +1,5 @@ {-# Language ViewPatterns, TypeOperators, KindSignatures, PolyKinds, - TypeInType, StandaloneDeriving, GADTs, RebindableSyntax, + StandaloneDeriving, GADTs, RebindableSyntax, RankNTypes, LambdaCase, PatternSynonyms, TypeApplications #-} module T12698 where diff --git a/testsuite/tests/patsyn/should_compile/T12968.hs b/testsuite/tests/patsyn/should_compile/T12968.hs index 9d38500d67..99626df1a7 100644 --- a/testsuite/tests/patsyn/should_compile/T12968.hs +++ b/testsuite/tests/patsyn/should_compile/T12968.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, GADTs, ScopedTypeVariables, PatternSynonyms, +{-# LANGUAGE PolyKinds , GADTs, ScopedTypeVariables, PatternSynonyms, ViewPatterns #-} module T12968 where diff --git a/testsuite/tests/patsyn/should_compile/T13768.hs b/testsuite/tests/patsyn/should_compile/T13768.hs index c4510bd20a..3dc3b84e7e 100644 --- a/testsuite/tests/patsyn/should_compile/T13768.hs +++ b/testsuite/tests/patsyn/should_compile/T13768.hs @@ -6,9 +6,11 @@ {-# LANGUAGE ViewPatterns #-} module T13768 where -data NS (f :: k -> *) (xs :: [k]) = NS Int +import Data.Kind (Type) -data IsNS (f :: k -> *) (xs :: [k]) where +data NS (f :: k -> Type) (xs :: [k]) = NS Int + +data IsNS (f :: k -> Type) (xs :: [k]) where IsZ :: f x -> IsNS f (x ': xs) IsS :: NS f xs -> IsNS f (x ': xs) @@ -23,7 +25,7 @@ pattern S p <- (isNS -> IsS p) {-# COMPLETE Z, S #-} -data SList :: [k] -> * where +data SList :: [k] -> Type where SNil :: SList '[] SCons :: SList (x ': xs) diff --git a/testsuite/tests/patsyn/should_compile/T14058.hs b/testsuite/tests/patsyn/should_compile/T14058.hs index 7c263b8f44..b2f7eea595 100644 --- a/testsuite/tests/patsyn/should_compile/T14058.hs +++ b/testsuite/tests/patsyn/should_compile/T14058.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T14058 where import T14058a (Sing(..)) diff --git a/testsuite/tests/patsyn/should_compile/T14058a.hs b/testsuite/tests/patsyn/should_compile/T14058a.hs index a7e5d97b79..5e27846d2c 100644 --- a/testsuite/tests/patsyn/should_compile/T14058a.hs +++ b/testsuite/tests/patsyn/should_compile/T14058a.hs @@ -2,7 +2,8 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T14058a (Sing(.., SCons)) where diff --git a/testsuite/tests/patsyn/should_fail/T14507.hs b/testsuite/tests/patsyn/should_fail/T14507.hs index 84166d0286..b36425ced6 100644 --- a/testsuite/tests/patsyn/should_fail/T14507.hs +++ b/testsuite/tests/patsyn/should_fail/T14507.hs @@ -1,4 +1,6 @@ -{-# Language PatternSynonyms, ViewPatterns, GADTs, ConstraintKinds, RankNTypes, KindSignatures, PolyKinds, ScopedTypeVariables, DataKinds, TypeInType, TypeOperators, TypeApplications, TypeFamilies, TypeFamilyDependencies #-} +{-# Language PatternSynonyms, ViewPatterns, GADTs, ConstraintKinds, RankNTypes, + PolyKinds, ScopedTypeVariables, DataKinds, TypeOperators, + TypeApplications, TypeFamilies, TypeFamilyDependencies #-} module T14507 where diff --git a/testsuite/tests/patsyn/should_fail/T14507.stderr b/testsuite/tests/patsyn/should_fail/T14507.stderr index cec70dfcdb..1279ec1e4e 100644 --- a/testsuite/tests/patsyn/should_fail/T14507.stderr +++ b/testsuite/tests/patsyn/should_fail/T14507.stderr @@ -1,5 +1,5 @@ -T14507.hs:18:9: error: +T14507.hs:20:9: error: • Iceland Jack! Iceland Jack! Stop torturing me! Pattern-bound variable x :: TypeRep a has a type that mentions pattern-bound coercion: co diff --git a/testsuite/tests/patsyn/should_fail/T14552.hs b/testsuite/tests/patsyn/should_fail/T14552.hs index 77f08575b1..a4a7493530 100644 --- a/testsuite/tests/patsyn/should_fail/T14552.hs +++ b/testsuite/tests/patsyn/should_fail/T14552.hs @@ -1,5 +1,5 @@ {-# Language RankNTypes, ViewPatterns, PatternSynonyms, TypeOperators, ScopedTypeVariables, - KindSignatures, PolyKinds, DataKinds, TypeFamilies, TypeInType, GADTs #-} + KindSignatures, PolyKinds, DataKinds, TypeFamilies, GADTs #-} module T14552 where diff --git a/testsuite/tests/perf/compiler/T12227.hs b/testsuite/tests/perf/compiler/T12227.hs index a97ff69f45..9be515f083 100644 --- a/testsuite/tests/perf/compiler/T12227.hs +++ b/testsuite/tests/perf/compiler/T12227.hs @@ -13,25 +13,26 @@ module Crash where import Data.Proxy (Proxy(..)) import Data.Type.Equality (type (==)) +import Data.Kind import GHC.Exts import GHC.Generics -data Dict :: Constraint -> * where +data Dict :: Constraint -> Type where Dict :: a => Dict a infixr 0 --> -type family (args :: [*]) --> (ret :: *) :: * +type family (args :: [Type]) --> (ret :: Type) :: Type where '[] --> ret = ret (arg ': args) --> ret = arg -> (args --> ret) -type family AllArguments (func :: *) :: [*] +type family AllArguments (func :: Type) :: [Type] where AllArguments (arg -> func) = arg ': AllArguments func AllArguments ret = '[] -type family FinalReturn (func :: *) :: * +type family FinalReturn (func :: Type) :: Type where FinalReturn (arg -> func) = FinalReturn func FinalReturn ret = ret @@ -39,11 +40,11 @@ type family FinalReturn (func :: *) :: * type IsFullFunction f = (AllArguments f --> FinalReturn f) ~ f -type family SConstructor (struct :: *) :: * +type family SConstructor (struct :: Type) :: Type where SConstructor struct = GPrependFields (Rep struct ()) '[] --> struct -type family GPrependFields (gstruct :: *) (tail :: [*]) :: [*] +type family GPrependFields (gstruct :: Type) (tail :: [Type]) :: [Type] where GPrependFields (M1 i t f p) tail = GPrependFields (f p) tail GPrependFields (K1 i c p) tail = c ': tail @@ -60,7 +61,7 @@ instance AppendFields fields1 fields2 fields r => AppendFields (f ': fields1) fields2 (f ': fields) r class Generic struct - => GoodConstructor (struct :: *) + => GoodConstructor (struct :: Type) where goodConstructor :: Proxy struct -> Dict ( IsFullFunction (SConstructor struct) @@ -79,7 +80,7 @@ instance ( Generic struct (Proxy :: Proxy struct) {-# INLINE goodConstructor #-} -class GoodConstructorEq (isEqual :: Bool) (ctor :: *) (struct :: *) +class GoodConstructorEq (isEqual :: Bool) (ctor :: Type) (struct :: Type) where goodConstructorEq :: Proxy isEqual -> Proxy ctor diff --git a/testsuite/tests/perf/compiler/T12545a.hs b/testsuite/tests/perf/compiler/T12545a.hs index 3002085499..4eceb91d02 100644 --- a/testsuite/tests/perf/compiler/T12545a.hs +++ b/testsuite/tests/perf/compiler/T12545a.hs @@ -19,6 +19,7 @@ module T12545a , ElemsOf ) where +import Data.Kind (Type) import Data.Proxy (Proxy(..)) data ElemPath = HeadElem @@ -55,4 +56,4 @@ type IsElem a l = ElemAt (JustElemPath (FindElem 'HeadElem a l)) a l class IsElem t (ElemsOf a) => ElemOf a t where -type family ElemsOf a :: [*] +type family ElemsOf a :: [Type] diff --git a/testsuite/tests/perf/compiler/T13035.hs b/testsuite/tests/perf/compiler/T13035.hs index 4c001cf3e1..b8d294def5 100644 --- a/testsuite/tests/perf/compiler/T13035.hs +++ b/testsuite/tests/perf/compiler/T13035.hs @@ -1,7 +1,10 @@ -{-# LANGUAGE PolyKinds, DataKinds, TypeOperators, TypeFamilies, GADTs, PartialTypeSignatures #-} +{-# LANGUAGE PolyKinds, DataKinds, TypeOperators, TypeFamilies, + GADTs, PartialTypeSignatures #-} module T13035 where +import Data.Kind + newtype MyAttr a b = MyAttr { _unMyAttr :: MyFun (a b) } type MyRec a b = Rec (MyAttr a) b @@ -26,9 +29,9 @@ type (a :: j1 -> j2) $ (b :: j1) = a b infixr 0 $ infixr 9 =: -data FConst (a :: *) (b :: Fields) -data FApply (a :: * -> * -> *) b c (d :: Fields) -data FMap (a :: * -> *) b (d :: Fields) +data FConst (a :: Type) (b :: Fields) +data FApply (a :: Type -> Type -> Type) b c (d :: Fields) +data FMap (a :: Type -> Type) b (d :: Fields) type instance MyFun (FConst a b) = a type instance MyFun (FApply b c d a) = b (MyFun (c a)) (MyFun (d a)) @@ -63,7 +66,7 @@ data Fields = Name | UnsaturatedFat | ServingSize -data Rec :: (u -> *) -> [u] -> * where +data Rec :: (u -> Type) -> [u] -> Type where RNil :: Rec f '[] (:&) :: !(f r) -> !(Rec f rs) -> Rec f (r ': rs) diff --git a/testsuite/tests/perf/compiler/T13035.stderr b/testsuite/tests/perf/compiler/T13035.stderr index 4fbc7c7e37..3dca3d71f2 100644 --- a/testsuite/tests/perf/compiler/T13035.stderr +++ b/testsuite/tests/perf/compiler/T13035.stderr @@ -1,4 +1,4 @@ -T13035.hs:141:28: warning: [-Wpartial-type-signatures (in -Wdefault)] +T13035.hs:144:28: warning: [-Wpartial-type-signatures (in -Wdefault)] • Found type wildcard ‘_’ standing for ‘'[ 'Author] :: [Fields]’ • In the type signature: g :: MyRec RecipeFormatter _ diff --git a/testsuite/tests/perf/compiler/T9872d.hs b/testsuite/tests/perf/compiler/T9872d.hs index 4930ffecfe..5c859eefdc 100644 --- a/testsuite/tests/perf/compiler/T9872d.hs +++ b/testsuite/tests/perf/compiler/T9872d.hs @@ -16,30 +16,32 @@ module T9872d where -- families. Code in this file was extracted from encoding generated -- automatically with Template Haskell by singletons library. +import Data.Kind import GHC.TypeLits -- encoding of type-level partially applied functions -data TyFun :: * -> * -> * -type family Apply (f :: TyFun k1 k2 -> *) (x :: k1) :: k2 +data TyFun :: Type -> Type -> Type +type family Apply (f :: TyFun k1 k2 -> Type) (x :: k1) :: k2 type a @@ b = Apply a b -- some boilerplate type family Error (a :: k) :: k1 type ErrorSym1 a = Error a -data ErrorSym0 :: TyFun a b -> * +data ErrorSym0 :: TyFun a b -> Type type instance Apply ErrorSym0 e = Error e data Proxy a = Proxy -data KProxy (a :: *) = KProxy +data KProxy (a :: Type) = KProxy type KindOf (a :: k) = ('KProxy :: KProxy k) -- type-level addition type (:+$$$) (t1 :: Nat) (t2 :: Nat) = t1 + t2 data (:+$$) (l :: Nat) (tf :: TyFun Nat Nat) - = forall a. (KindOf (Apply ((:+$$) l) a)) ~ (KindOf ((:+$$$) l a)) => (:+$$###) + = forall a. (KindOf (Apply ((:+$$) l) a)) ~ (KindOf ((:+$$$) l a)) => + (:+$$###) type instance Apply ((:+$$) l1) l2 = (:+$$$) l1 l2 -data (:+$) (l :: TyFun Nat (TyFun Nat Nat -> *)) +data (:+$) (l :: TyFun Nat (TyFun Nat Nat -> Type)) = forall a. (KindOf (Apply (:+$) a)) ~ (KindOf ((:+$$) a)) => (:+$###) type instance Apply (:+$) l = (:+$$) l @@ -49,10 +51,11 @@ type NilSym0 = '[] type ConsSym2 (x :: a) (xs :: [a]) = x ': xs data ConsSym1 (x :: a) (l_a3t6 :: TyFun [a] [a]) - = forall b. (KindOf (Apply (ConsSym1 x) b)) ~ (KindOf (ConsSym2 x b)) => (:$$###) + = forall b. (KindOf (Apply (ConsSym1 x) b)) ~ (KindOf (ConsSym2 x b)) => + (:$$###) type instance Apply (ConsSym1 x) xs = ConsSym2 x xs -data ConsSym0 (l :: TyFun a (TyFun [a] [a] -> *)) +data ConsSym0 (l :: TyFun a (TyFun [a] [a] -> Type)) = forall a. (KindOf (Apply ConsSym0 a)) ~ (KindOf (ConsSym1 a)) => (:$###) type instance Apply ConsSym0 l = ConsSym1 l @@ -63,22 +66,41 @@ data Let_1627403919Scrutinee_1627403894Sym3 l_a3Dx l_a3Dy l_a3Dz l_a3Dw - = forall arg_a3DA. (KindOf (Apply (Let_1627403919Scrutinee_1627403894Sym3 l_a3Dx l_a3Dy l_a3Dz) arg_a3DA)) ~ (KindOf (Let_1627403919Scrutinee_1627403894Sym4 l_a3Dx l_a3Dy l_a3Dz arg_a3DA)) => + = forall arg_a3DA. (KindOf (Apply (Let_1627403919Scrutinee_1627403894Sym3 + l_a3Dx l_a3Dy l_a3Dz) arg_a3DA)) ~ + (KindOf (Let_1627403919Scrutinee_1627403894Sym4 + l_a3Dx l_a3Dy l_a3Dz arg_a3DA)) => Let_1627403919Scrutinee_1627403894Sym3KindInference -type instance Apply (Let_1627403919Scrutinee_1627403894Sym3 l_a3Dx l_a3Dy l_a3Dz) l_a3Dw = Let_1627403919Scrutinee_1627403894Sym4 l_a3Dx l_a3Dy l_a3Dz l_a3Dw +type instance Apply (Let_1627403919Scrutinee_1627403894Sym3 + l_a3Dx l_a3Dy l_a3Dz) l_a3Dw = + Let_1627403919Scrutinee_1627403894Sym4 l_a3Dx l_a3Dy l_a3Dz l_a3Dw data Let_1627403919Scrutinee_1627403894Sym2 l_a3Dt l_a3Du l_a3Ds - = forall arg_a3Dv. (KindOf (Apply (Let_1627403919Scrutinee_1627403894Sym2 l_a3Dt l_a3Du) arg_a3Dv)) ~ (KindOf (Let_1627403919Scrutinee_1627403894Sym3 l_a3Dt l_a3Du arg_a3Dv)) => + = forall arg_a3Dv. (KindOf (Apply (Let_1627403919Scrutinee_1627403894Sym2 + l_a3Dt l_a3Du) arg_a3Dv)) ~ + (KindOf (Let_1627403919Scrutinee_1627403894Sym3 + l_a3Dt l_a3Du arg_a3Dv)) => Let_1627403919Scrutinee_1627403894Sym2KindInference -type instance Apply (Let_1627403919Scrutinee_1627403894Sym2 l_a3Dt l_a3Du) l_a3Ds = Let_1627403919Scrutinee_1627403894Sym3 l_a3Dt l_a3Du l_a3Ds +type instance Apply + (Let_1627403919Scrutinee_1627403894Sym2 l_a3Dt l_a3Du) l_a3Ds = + Let_1627403919Scrutinee_1627403894Sym3 l_a3Dt l_a3Du l_a3Ds data Let_1627403919Scrutinee_1627403894Sym1 l_a3Dq l_a3Dp - = forall arg_a3Dr. (KindOf (Apply (Let_1627403919Scrutinee_1627403894Sym1 l_a3Dq) arg_a3Dr)) ~ (KindOf (Let_1627403919Scrutinee_1627403894Sym2 l_a3Dq arg_a3Dr)) => + = forall arg_a3Dr. (KindOf (Apply (Let_1627403919Scrutinee_1627403894Sym1 + l_a3Dq) arg_a3Dr)) ~ + (KindOf (Let_1627403919Scrutinee_1627403894Sym2 + l_a3Dq arg_a3Dr)) => Let_1627403919Scrutinee_1627403894Sym1KindInference -type instance Apply (Let_1627403919Scrutinee_1627403894Sym1 l_a3Dq) l_a3Dp = Let_1627403919Scrutinee_1627403894Sym2 l_a3Dq l_a3Dp +type instance Apply (Let_1627403919Scrutinee_1627403894Sym1 l_a3Dq) + l_a3Dp + = Let_1627403919Scrutinee_1627403894Sym2 l_a3Dq l_a3Dp data Let_1627403919Scrutinee_1627403894Sym0 l_a3Dn - = forall arg_a3Do. (KindOf (Apply Let_1627403919Scrutinee_1627403894Sym0 arg_a3Do)) ~ (KindOf (Let_1627403919Scrutinee_1627403894Sym1 arg_a3Do)) => + = forall arg_a3Do. (KindOf (Apply Let_1627403919Scrutinee_1627403894Sym0 + arg_a3Do)) ~ + (KindOf (Let_1627403919Scrutinee_1627403894Sym1 + arg_a3Do)) => Let_1627403919Scrutinee_1627403894Sym0KindInference -type instance Apply Let_1627403919Scrutinee_1627403894Sym0 l_a3Dn = Let_1627403919Scrutinee_1627403894Sym1 l_a3Dn +type instance Apply Let_1627403919Scrutinee_1627403894Sym0 l_a3Dn + = Let_1627403919Scrutinee_1627403894Sym1 l_a3Dn type Let_1627403919Scrutinee_1627403894 f_a3Dd q0_a3De x_a3Df @@ -90,60 +112,154 @@ type family Case f q0 x xs t :: [k] where Case f q0 x xs (q ': qs) = ConsSym0 @@ (f @@ x @@ q) @@ (ConsSym0 @@ q @@ qs) -- type-level scanr -type ScanrSym3 (t1 :: TyFun a (TyFun b b -> *) -> *) (t2 :: b) (t3 :: [a]) = +type ScanrSym3 (t1 :: TyFun a (TyFun b b -> Type) -> Type) + (t2 :: b) + (t3 :: [a]) = Scanr t1 t2 t3 -data ScanrSym2 (l1 :: TyFun a (TyFun b b -> *) -> *) (l2 :: b) (l3 :: TyFun [a] [b]) - = forall a. (KindOf (Apply (ScanrSym2 l1 l2) a)) ~ (KindOf (ScanrSym3 l1 l2 a)) => +data ScanrSym2 (l1 :: TyFun a (TyFun b b -> Type) -> Type) + (l2 :: b) + (l3 :: TyFun [a] [b]) + = forall a. (KindOf (Apply (ScanrSym2 l1 l2) a)) ~ + (KindOf (ScanrSym3 l1 l2 a)) => ScanrSym2KindInference type instance Apply (ScanrSym2 l1 l2) l3 = ScanrSym3 l1 l2 l3 -data ScanrSym1 (l_a3D0 :: TyFun a_a3CJ (TyFun b_a3CK b_a3CK -> *) -> *) +data ScanrSym1 (l_a3D0 :: TyFun a_a3CJ (TyFun b_a3CK b_a3CK -> Type) -> Type) (l_a3CZ :: TyFun b_a3CK (TyFun ([a_a3CJ]) ([b_a3CK]) - -> *)) - = forall arg_a3D1. (KindOf (Apply (ScanrSym1 l_a3D0) arg_a3D1)) ~ (KindOf (ScanrSym2 l_a3D0 arg_a3D1)) => + -> Type)) + = forall arg_a3D1. (KindOf (Apply (ScanrSym1 l_a3D0) arg_a3D1)) ~ + (KindOf (ScanrSym2 l_a3D0 arg_a3D1)) => ScanrSym1KindInference type instance Apply (ScanrSym1 l_a3D0) l_a3CZ = ScanrSym2 l_a3D0 l_a3CZ -data ScanrSym0 (l :: TyFun (TyFun a (TyFun b b -> *) -> *) - (TyFun b (TyFun [a] [b] -> *) -> *)) +data ScanrSym0 (l :: TyFun (TyFun a (TyFun b b -> Type) -> Type) + (TyFun b (TyFun [a] [b] -> Type) -> Type)) = forall a. (KindOf (Apply ScanrSym0 a)) ~ (KindOf (ScanrSym1 a)) => ScanrSym0KindInference type instance Apply ScanrSym0 l1 = ScanrSym1 l1 -type family Scanr (a_a3D6 :: TyFun a_a3CJ (TyFun b_a3CK b_a3CK -> *) -> *) +type family Scanr (a_a3D6 :: TyFun a_a3CJ (TyFun b_a3CK b_a3CK -> Type) -> Type) (a_a3D7 :: b_a3CK) (a_a3D8 :: [a_a3CJ]) :: [b_a3CK] where Scanr _z_1627403911_a3Db q0_a3Dc '[] = Apply (Apply ConsSym0 q0_a3Dc) NilSym0 - Scanr f_a3Dd q0_a3De (x_a3Df ': xs_a3Dg) = Case f_a3Dd q0_a3De x_a3Df xs_a3Dg (Let_1627403919Scrutinee_1627403894Sym4 f_a3Dd q0_a3De x_a3Df xs_a3Dg) + Scanr f_a3Dd q0_a3De (x_a3Df ': xs_a3Dg) = + Case f_a3Dd q0_a3De x_a3Df xs_a3Dg (Let_1627403919Scrutinee_1627403894Sym4 + f_a3Dd q0_a3De x_a3Df xs_a3Dg) {- -foo32 :: Proxy ('[528,527,525,522,518,513,507,500,492,483,473,462,450,437,423,408,392,375,357,338,318,297,275,252,228,203,177,150,122,93,63,32,0]) +foo32 :: Proxy ('[528,527,525,522,518,513,507,500,492,483,473,462,450,437,423, + 408,392,375,357,338,318,297,275,252,228,203,177,150,122,93, + 63,32,0]) foo32 = Proxy -bar32 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]) +bar32 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24,25, + 26,27,28,29,30,31,32]) bar32 = foo32 -} {- -foo64 :: Proxy ('[2080,2079,2077,2074,2070,2065,2059,2052,2044,2035,2025,2014,2002,1989,1975,1960,1944,1927,1909,1890,1870,1849,1827,1804,1780,1755,1729,1702,1674,1645,1615,1584,1552,1519,1485,1450,1414,1377,1339,1300,1260,1219,1177,1134,1090,1045,999,952,904,855,805,754,702,649,595,540,484,427,369,310,250,189,127,64,0]) +foo64 :: Proxy ('[2080,2079,2077,2074,2070,2065,2059,2052,2044,2035,2025,2014, + 2002,1989,1975,1960,1944,1927,1909,1890,1870,1849,1827,1804, + 1780,1755,1729,1702,1674,1645,1615,1584,1552,1519,1485,1450, + 1414,1377,1339,1300,1260,1219,1177,1134,1090,1045,999,952,904, + 855,805,754,702,649,595,540,484,427,369,310,250,189,127,64,0]) foo64 = Proxy -bar64 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64]) +bar64 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24,25, + 26,27,28,29,30,31,32,33,34,35,36, + 37,38,39,40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55,56,57,58, + 59,60,61,62,63,64]) bar64 = foo64 -foo128 :: Proxy ('[8256,8255,8253,8250,8246,8241,8235,8228,8220,8211,8201,8190,8178,8165,8151,8136,8120,8103,8085,8066,8046,8025,8003,7980,7956,7931,7905,7878,7850,7821,7791,7760,7728,7695,7661,7626,7590,7553,7515,7476,7436,7395,7353,7310,7266,7221,7175,7128,7080,7031,6981,6930,6878,6825,6771,6716,6660,6603,6545,6486,6426,6365,6303,6240,6176,6111,6045,5978,5910,5841,5771,5700,5628,5555,5481,5406,5330,5253,5175,5096,5016,4935,4853,4770,4686,4601,4515,4428,4340,4251,4161,4070,3978,3885,3791,3696,3600,3503,3405,3306,3206,3105,3003,2900,2796,2691,2585,2478,2370,2261,2151,2040,1928,1815,1701,1586,1470,1353,1235,1116,996,875,753,630,506,381,255,128,0]) +foo128 :: Proxy ('[8256,8255,8253,8250,8246,8241,8235,8228,8220,8211,8201,8190, + 8178,8165,8151,8136,8120,8103,8085,8066,8046,8025,8003,7980, + 7956,7931,7905,7878,7850,7821,7791,7760,7728,7695,7661,7626, + 7590,7553,7515,7476,7436,7395,7353,7310,7266,7221,7175,7128, + 7080,7031,6981,6930,6878,6825,6771,6716,6660,6603,6545,6486, + 6426,6365,6303,6240,6176,6111,6045,5978,5910,5841,5771,5700, + 5628,5555,5481,5406,5330,5253,5175,5096,5016,4935,4853,4770, + 4686,4601,4515,4428,4340,4251,4161,4070,3978,3885,3791,3696, + 3600,3503,3405,3306,3206,3105,3003,2900,2796,2691,2585,2478, + 2370,2261,2151,2040,1928,1815,1701,1586,1470,1353,1235,1116, + 996,875,753,630,506,381,255,128,0]) foo128 = Proxy -bar128 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128]) +bar128 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24,25, + 26,27,28,29,30,31,32,33,34,35,36, + 37,38,39,40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55,56,57,58, + 59,60,61,62,63,64,65,66,67,68,69, + 70,71,72,73,74,75,76,77,78,79,80, + 81,82,83,84,85,86,87,88,89,90,91, + 92,93,94,95,96,97,98,99,100,101, + 102,103,104,105,106,107,108,109, + 110,111,112,113,114,115,116,117, + 118,119,120,121,122,123,124,125, + 126,127,128]) bar128 = foo128 -} -foo256 :: Proxy ('[32896,32895,32893,32890,32886,32881,32875,32868,32860,32851,32841,32830,32818,32805,32791,32776,32760,32743,32725,32706,32686,32665,32643,32620,32596,32571,32545,32518,32490,32461,32431,32400,32368,32335,32301,32266,32230,32193,32155,32116,32076,32035,31993,31950,31906,31861,31815,31768,31720,31671,31621,31570,31518,31465,31411,31356,31300,31243,31185,31126,31066,31005,30943,30880,30816,30751,30685,30618,30550,30481,30411,30340,30268,30195,30121,30046,29970,29893,29815,29736,29656,29575,29493,29410,29326,29241,29155,29068,28980,28891,28801,28710,28618,28525,28431,28336,28240,28143,28045,27946,27846,27745,27643,27540,27436,27331,27225,27118,27010,26901,26791,26680,26568,26455,26341,26226,26110,25993,25875,25756,25636,25515,25393,25270,25146,25021,24895,24768,24640,24511,24381,24250,24118,23985,23851,23716,23580,23443,23305,23166,23026,22885,22743,22600,22456,22311,22165,22018,21870,21721,21571,21420,21268,21115,20961,20806,20650,20493,20335,20176,20016,19855,19693,19530,19366,19201,19035,18868,18700,18531,18361,18190,18018,17845,17671,17496,17320,17143,16965,16786,16606,16425,16243,16060,15876,15691,15505,15318,15130,14941,14751,14560,14368,14175,13981,13786,13590,13393,13195,12996,12796,12595,12393,12190,11986,11781,11575,11368,11160,10951,10741,10530,10318,10105,9891,9676,9460,9243,9025,8806,8586,8365,8143,7920,7696,7471,7245,7018,6790,6561,6331,6100,5868,5635,5401,5166,4930,4693,4455,4216,3976,3735,3493,3250,3006,2761,2515,2268,2020,1771,1521,1270,1018,765,511,256,0]) +foo256 :: Proxy ('[32896,32895,32893,32890,32886,32881,32875,32868,32860,32851, + 32841,32830,32818,32805,32791,32776,32760,32743,32725,32706, + 32686,32665,32643,32620,32596,32571,32545,32518,32490,32461, + 32431,32400,32368,32335,32301,32266,32230,32193,32155,32116, + 32076,32035,31993,31950,31906,31861,31815,31768,31720,31671, + 31621,31570,31518,31465,31411,31356,31300,31243,31185,31126, + 31066,31005,30943,30880,30816,30751,30685,30618,30550,30481, + 30411,30340,30268,30195,30121,30046,29970,29893,29815,29736, + 29656,29575,29493,29410,29326,29241,29155,29068,28980,28891, + 28801,28710,28618,28525,28431,28336,28240,28143,28045,27946, + 27846,27745,27643,27540,27436,27331,27225,27118,27010,26901, + 26791,26680,26568,26455,26341,26226,26110,25993,25875,25756, + 25636,25515,25393,25270,25146,25021,24895,24768,24640,24511, + 24381,24250,24118,23985,23851,23716,23580,23443,23305,23166, + 23026,22885,22743,22600,22456,22311,22165,22018,21870,21721, + 21571,21420,21268,21115,20961,20806,20650,20493,20335,20176, + 20016,19855,19693,19530,19366,19201,19035,18868,18700,18531, + 18361,18190,18018,17845,17671,17496,17320,17143,16965,16786, + 16606,16425,16243,16060,15876,15691,15505,15318,15130,14941, + 14751,14560,14368,14175,13981,13786,13590,13393,13195,12996, + 12796,12595,12393,12190,11986,11781,11575,11368,11160,10951, + 10741,10530,10318,10105,9891,9676,9460,9243,9025,8806, + 8586,8365,8143,7920,7696,7471,7245,7018,6790,6561,6331,6100, + 5868,5635,5401,5166,4930,4693,4455,4216,3976,3735,3493,3250, + 3006,2761,2515,2268,2020,1771,1521,1270,1018,765,511,256,0]) foo256 = Proxy -bar256 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256]) +bar256 :: Proxy (ScanrSym0 @@ (:+$) @@ 0 @@ '[1,2,3,4,5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24,25, + 26,27,28,29,30,31,32,33,34,35,36, + 37,38,39,40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55,56,57,58, + 59,60,61,62,63,64,65,66,67,68,69, + 70,71,72,73,74,75,76,77,78,79,80, + 81,82,83,84,85,86,87,88,89,90,91, + 92,93,94,95,96,97,98,99,100,101, + 102,103,104,105,106,107,108,109, + 110,111,112,113,114,115,116,117, + 118,119,120,121,122,123,124,125, + 126,127,128,129,130,131,132,133, + 134,135,136,137,138,139,140,141, + 142,143,144,145,146,147,148,149, + 150,151,152,153,154,155,156,157, + 158,159,160,161,162,163,164,165, + 166,167,168,169,170,171,172,173, + 174,175,176,177,178,179,180,181, + 182,183,184,185,186,187,188,189, + 190,191,192,193,194,195,196,197, + 198,199,200,201,202,203,204,205, + 206,207,208,209,210,211,212,213, + 214,215,216,217,218,219,220,221, + 222,223,224,225,226,227,228,229, + 230,231,232,233,234,235,236,237, + 238,239,240,241,242,243,244,245, + 246,247,248,249,250,251,252,253, + 254,255,256]) bar256 = foo256 - diff --git a/testsuite/tests/pmcheck/complete_sigs/T14253.hs b/testsuite/tests/pmcheck/complete_sigs/T14253.hs index 88cc4f88b3..bb56d437bf 100644 --- a/testsuite/tests/pmcheck/complete_sigs/T14253.hs +++ b/testsuite/tests/pmcheck/complete_sigs/T14253.hs @@ -2,7 +2,7 @@ {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T14253 where diff --git a/testsuite/tests/pmcheck/should_compile/T14086.hs b/testsuite/tests/pmcheck/should_compile/T14086.hs index de91229c24..5e69ce6a33 100644 --- a/testsuite/tests/pmcheck/should_compile/T14086.hs +++ b/testsuite/tests/pmcheck/should_compile/T14086.hs @@ -1,4 +1,4 @@ -{-# language TypeInType, EmptyCase #-} +{-# language EmptyCase #-} module T14086 where import Data.Kind diff --git a/testsuite/tests/pmcheck/should_compile/T3927b.hs b/testsuite/tests/pmcheck/should_compile/T3927b.hs index 89b81534c7..d4cfa1e275 100644 --- a/testsuite/tests/pmcheck/should_compile/T3927b.hs +++ b/testsuite/tests/pmcheck/should_compile/T3927b.hs @@ -11,8 +11,8 @@ module T3927b where +import Data.Kind (Type, Constraint) import Data.Proxy -import GHC.Exts data Message @@ -30,16 +30,16 @@ type family Implements (t :: SocketType) :: [SocketOperation] where Implements Push = '[Write] Implements Pull = '[ 'Read] -data SockOp :: SocketType -> SocketOperation -> * where +data SockOp :: SocketType -> SocketOperation -> Type where SRead :: SockOp sock 'Read SWrite :: SockOp sock Write -data Socket :: SocketType -> * where +data Socket :: SocketType -> Type where Socket :: proxy sock -> (forall op . Restrict op (Implements sock) => SockOp sock op -> Operation op) -> Socket sock -type family Operation (op :: SocketOperation) :: * where +type family Operation (op :: SocketOperation) :: Type where Operation 'Read = IO Message Operation Write = Message -> IO () diff --git a/testsuite/tests/polykinds/MonoidsTF.hs b/testsuite/tests/polykinds/MonoidsTF.hs index 365c3766bc..8e3b378046 100644 --- a/testsuite/tests/polykinds/MonoidsTF.hs +++ b/testsuite/tests/polykinds/MonoidsTF.hs @@ -12,13 +12,15 @@ {-# LANGUAGE TypeFamilies #-} module Main where + +import Data.Kind import Control.Monad (Monad(..), join, ap, liftM) import Data.Monoid (Monoid(..)) import Data.Semigroup (Semigroup(..)) -- First we define the type class Monoidy: -class Monoidy (to :: k0 -> k1 -> *) (m :: k1) where +class Monoidy (to :: k0 -> k1 -> Type) (m :: k1) where type MComp to m :: k1 -> k1 -> k0 type MId to m :: k0 munit :: MId to m `to` m diff --git a/testsuite/tests/polykinds/PolyKinds10.hs b/testsuite/tests/polykinds/PolyKinds10.hs index b023fd092f..70c5d70606 100644 --- a/testsuite/tests/polykinds/PolyKinds10.hs +++ b/testsuite/tests/polykinds/PolyKinds10.hs @@ -9,6 +9,7 @@ module Main where +import Data.Kind -- Type-level peano naturals (value-level too, but we don't use those) data Nat = Ze | Su Nat @@ -18,15 +19,15 @@ type T1 = Su T0 type T2 = Su T1 -- (!) at the type level -type family El (n :: Nat) (l :: [*]) :: * +type family El (n :: Nat) (l :: [Type]) :: Type type instance El Ze (h ': t) = h type instance El (Su n) (h ': t) = El n t {- -- The following might be useful, but are not used at the moment -- ($) at the type level (well, not quite ($), in fact...) -class Apply (fs :: [*]) (es :: [*]) where - type ApplyT (fs :: [*]) (es :: [*]) :: [*] +class Apply (fs :: [Type]) (es :: [Type]) where + type ApplyT (fs :: [Type]) (es :: [Type]) :: [Type] apply :: ListV fs -> ListV es -> ListV (ApplyT fs es) instance Apply '[] '[] where @@ -39,11 +40,11 @@ instance (Apply fs es) => Apply ((e1 -> e2) ': fs) (e1 ': es) where -} -- Value mirror for the list kind -data ListV :: [*] -> * where +data ListV :: [Type] -> Type where NilV :: ListV '[] ConsV :: a -> ListV t -> ListV (a ': t) -data ListV2 :: [[*]] -> * where +data ListV2 :: [[Type]] -> Type where NilV2 :: ListV2 '[] ConsV2 :: ListV a -> ListV2 t -> ListV2 (a ': t) @@ -53,26 +54,26 @@ listv1 = ConsV 3 NilV listv2 :: ListV2 ((Int ': '[]) ': '[]) listv2 = ConsV2 listv1 NilV2 ---data ListVX :: Maybe -> * where +--data ListVX :: Maybe -> Type where -data TripleV :: (*, * -> *, *) -> * where +data TripleV :: (Type, Type -> Type, Type) -> Type where TripleV :: a -> c -> TripleV '(a, [], c) -- Value mirror for the Nat kind -data NatV :: Nat -> * where +data NatV :: Nat -> Type where ZeW :: NatV Ze SuW :: NatV n -> NatV (Su n) -- Generic universe data MultiP x = UNIT - | KK x -- wish I could just write * instead of x + | KK x -- wish I could just write Type instead of x | SUM (MultiP x) (MultiP x) | PROD (MultiP x) (MultiP x) | PAR Nat | REC -- Universe interpretation -data Interprt :: MultiP * -> [*] -> * -> * where +data Interprt :: MultiP Type -> [Type] -> Type -> Type where Unit :: Interprt UNIT lp r K :: x -> Interprt (KK x) lp r L :: Interprt a lp r -> Interprt (SUM a b) lp r @@ -83,13 +84,13 @@ data Interprt :: MultiP * -> [*] -> * -> * where -- Embedding values into the universe class Generic a where - type Rep a :: MultiP * - type Es a :: [*] + type Rep a :: MultiP Type + type Es a :: [Type] from :: a -> Interprt (Rep a) (Es a) a to :: Interprt (Rep a) (Es a) a -> a -- Parameter map over the universe -class PMap (rep :: MultiP *) where +class PMap (rep :: MultiP Type) where pmap :: (forall n. NatV n -> El n lp1 -> El n lp2) -> (r -> s) -> Interprt rep lp1 r -> Interprt rep lp2 s diff --git a/testsuite/tests/polykinds/SigTvKinds3.hs b/testsuite/tests/polykinds/SigTvKinds3.hs index b27be2e9c6..7c9dace054 100644 --- a/testsuite/tests/polykinds/SigTvKinds3.hs +++ b/testsuite/tests/polykinds/SigTvKinds3.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, ExplicitForAll, TypeInType #-} +{-# LANGUAGE GADTs, ExplicitForAll, PolyKinds #-} module SigTvKinds3 where diff --git a/testsuite/tests/polykinds/T10134a.hs b/testsuite/tests/polykinds/T10134a.hs index 0d84d56b5e..9412705e4c 100644 --- a/testsuite/tests/polykinds/T10134a.hs +++ b/testsuite/tests/polykinds/T10134a.hs @@ -4,8 +4,9 @@ {-# LANGUAGE TypeOperators #-} module T10134a where +import Data.Kind (Type) import GHC.TypeLits -data Vec :: Nat -> * -> * where +data Vec :: Nat -> Type -> Type where Nil :: Vec 0 a (:>) :: a -> Vec n a -> Vec (n + 1) a diff --git a/testsuite/tests/polykinds/T10934.hs b/testsuite/tests/polykinds/T10934.hs index fb7a538ebd..35ea20f225 100644 --- a/testsuite/tests/polykinds/T10934.hs +++ b/testsuite/tests/polykinds/T10934.hs @@ -11,6 +11,8 @@ module KeyValue where +import Data.Kind + data AccValidation err a = AccFailure err | AccSuccess a data KeyValueError = MissingValue @@ -23,11 +25,11 @@ missing = rpure missingField missingField :: forall x. (WithKeyValueError :. f) x missingField = Compose $ AccFailure [MissingValue] -data Rec :: (u -> *) -> [u] -> * where +data Rec :: (u -> Type) -> [u] -> Type where RNil :: Rec f '[] (:&) :: !(f r) -> !(Rec f rs) -> Rec f (r ': rs) -newtype Compose (f :: l -> *) (g :: k -> l) (x :: k) +newtype Compose (f :: l -> Type) (g :: k -> l) (x :: k) = Compose { getCompose :: f (g x) } type (:.) f g = Compose f g diff --git a/testsuite/tests/polykinds/T11142.hs b/testsuite/tests/polykinds/T11142.hs index 58eb3b6c94..a96566a371 100644 --- a/testsuite/tests/polykinds/T11142.hs +++ b/testsuite/tests/polykinds/T11142.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, RankNTypes #-} +{-# LANGUAGE PolyKinds, RankNTypes #-} module T11142 where diff --git a/testsuite/tests/polykinds/T11399.hs b/testsuite/tests/polykinds/T11399.hs index bc9e60d7f3..56f3c11ef7 100644 --- a/testsuite/tests/polykinds/T11399.hs +++ b/testsuite/tests/polykinds/T11399.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE FlexibleInstances, TypeInType #-} +{-# LANGUAGE FlexibleInstances, PolyKinds #-} module T11399 where import Data.Kind diff --git a/testsuite/tests/polykinds/T11480b.hs b/testsuite/tests/polykinds/T11480b.hs index 12802e8de3..2684c6de4e 100644 --- a/testsuite/tests/polykinds/T11480b.hs +++ b/testsuite/tests/polykinds/T11480b.hs @@ -21,25 +21,25 @@ module T11480b where -import GHC.Types (Constraint) +import Data.Kind (Constraint, Type) import Data.Type.Equality as Equality import Data.Type.Coercion as Coercion import qualified Prelude import Prelude (Either(..)) -newtype Y (p :: i -> j -> *) (a :: j) (b :: i) = Y { getY :: p b a } +newtype Y (p :: i -> j -> Type) (a :: j) (b :: i) = Y { getY :: p b a } -type family Op (p :: i -> j -> *) :: j -> i -> * where +type family Op (p :: i -> j -> Type) :: j -> i -> Type where Op (Y p) = p Op p = Y p -class Vacuous (p :: i -> i -> *) (a :: i) +class Vacuous (p :: i -> i -> Type) (a :: i) instance Vacuous p a data Dict (p :: Constraint) where Dict :: p => Dict p -class Functor (Op p) (Nat p (->)) p => Category (p :: i -> i -> *) where +class Functor (Op p) (Nat p (->)) p => Category (p :: i -> i -> Type) where type Ob p :: i -> Constraint type Ob p = Vacuous p @@ -62,11 +62,16 @@ class Functor (Op p) (Nat p (->)) p => Category (p :: i -> i -> *) where default unop :: Op p ~ Y p => Op p b a -> p a b unop = getY -class (Category p, Category q) => Functor (p :: i -> i -> *) (q :: j -> j -> *) (f :: i -> j) | f -> p q where +class (Category p, Category q) => + Functor (p :: i -> i -> Type) + (q :: j -> j -> Type) + (f :: i -> j) | f -> p q where fmap :: p a b -> q (f a) (f b) -data Nat (p :: i -> i -> *) (q :: j -> j -> *) (f :: i -> j) (g :: i -> j) where - Nat :: (Functor p q f, Functor p q g) => { runNat :: forall a. Ob p a => q (f a) (g a) } -> Nat p q f g +data Nat (p :: i -> i -> Type) + (q :: j -> j -> Type) (f :: i -> j) (g :: i -> j) where + Nat :: (Functor p q f, Functor p q g) => + { runNat :: forall a. Ob p a => q (f a) (g a) } -> Nat p q f g instance (Category p, Category q) => Category (Nat p q) where type Ob (Nat p q) = Functor p q @@ -80,7 +85,8 @@ instance (Category p, Category q) => Category (Nat p q) where ob :: forall p q f a. Functor p q f => Ob p a :- Ob q (f a) ob = Sub (case source (fmap (id :: p a a) :: q (f a) (f a)) of Dict -> Dict) -instance (Category p, Category q) => Functor (Y (Nat p q)) (Nat (Nat p q) (->)) (Nat p q) where +instance (Category p, Category q) => + Functor (Y (Nat p q)) (Nat (Nat p q) (->)) (Nat p q) where fmap (Y f) = Nat (. f) instance (Category p, Category q) => Functor (Nat p q) (->) (Nat p q f) where diff --git a/testsuite/tests/polykinds/T11520.hs b/testsuite/tests/polykinds/T11520.hs index fa5a3bf4a4..eef999d4ba 100644 --- a/testsuite/tests/polykinds/T11520.hs +++ b/testsuite/tests/polykinds/T11520.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RankNTypes, PolyKinds, TypeInType, GADTs, UndecidableSuperClasses #-} +{-# LANGUAGE RankNTypes, PolyKinds, GADTs, UndecidableSuperClasses #-} module T11520 where diff --git a/testsuite/tests/polykinds/T11523.hs b/testsuite/tests/polykinds/T11523.hs index 0313b0c46e..aff0f9ed90 100644 --- a/testsuite/tests/polykinds/T11523.hs +++ b/testsuite/tests/polykinds/T11523.hs @@ -15,7 +15,6 @@ {-# language FunctionalDependencies #-} {-# language UndecidableSuperClasses #-} {-# language UndecidableInstances #-} -{-# language TypeInType #-} module T11523 where diff --git a/testsuite/tests/polykinds/T11554.hs b/testsuite/tests/polykinds/T11554.hs index e7a35bd9d8..bca6b8277c 100644 --- a/testsuite/tests/polykinds/T11554.hs +++ b/testsuite/tests/polykinds/T11554.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, TypeInType, RankNTypes #-} +{-# LANGUAGE GADTs, PolyKinds, RankNTypes #-} module T11554 where diff --git a/testsuite/tests/polykinds/T11616.hs b/testsuite/tests/polykinds/T11616.hs index 378032b7ed..16a62b33b2 100644 --- a/testsuite/tests/polykinds/T11616.hs +++ b/testsuite/tests/polykinds/T11616.hs @@ -1,6 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T11616 where class Whoami a where diff --git a/testsuite/tests/polykinds/T11640.hs b/testsuite/tests/polykinds/T11640.hs index bbb4a53bfc..ade4cbc79d 100644 --- a/testsuite/tests/polykinds/T11640.hs +++ b/testsuite/tests/polykinds/T11640.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, RankNTypes, TypeInType #-} +{-# LANGUAGE GADTs, RankNTypes, PolyKinds #-} module T11640 where diff --git a/testsuite/tests/polykinds/T11648.hs b/testsuite/tests/polykinds/T11648.hs index 15fcfa4e05..b8b70e8733 100644 --- a/testsuite/tests/polykinds/T11648.hs +++ b/testsuite/tests/polykinds/T11648.hs @@ -3,6 +3,8 @@ module T11648 where -class Monoidy (to :: k0 -> k1 -> *) (m :: k1) where +import Data.Kind + +class Monoidy (to :: k0 -> k1 -> Type) (m :: k1) where type MComp to m :: k1 -> k1 -> k0 mjoin :: MComp to m m m `to` m diff --git a/testsuite/tests/polykinds/T11648b.hs b/testsuite/tests/polykinds/T11648b.hs index 2ab27a6166..d50854d237 100644 --- a/testsuite/tests/polykinds/T11648b.hs +++ b/testsuite/tests/polykinds/T11648b.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T11648b where diff --git a/testsuite/tests/polykinds/T11821a.hs b/testsuite/tests/polykinds/T11821a.hs index da96fe2c56..c5de2bbe53 100644 --- a/testsuite/tests/polykinds/T11821a.hs +++ b/testsuite/tests/polykinds/T11821a.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, TypeInType, ConstraintKinds #-} +{-# LANGUAGE GADTs, DataKinds, PolyKinds, ConstraintKinds #-} module T11821a where import Data.Proxy type SameKind (a :: k1) (b :: k2) = ('Proxy :: Proxy k1) ~ ('Proxy :: Proxy k2) diff --git a/testsuite/tests/polykinds/T12055.hs b/testsuite/tests/polykinds/T12055.hs index 3ffc221b7b..cabc2dfbba 100644 --- a/testsuite/tests/polykinds/T12055.hs +++ b/testsuite/tests/polykinds/T12055.hs @@ -3,9 +3,9 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} -- The code from the ticket lacked these extensions, -- but crashed the compiler with "GHC internal error" diff --git a/testsuite/tests/polykinds/T12055a.hs b/testsuite/tests/polykinds/T12055a.hs index dab523861b..ebc4dc7cad 100644 --- a/testsuite/tests/polykinds/T12055a.hs +++ b/testsuite/tests/polykinds/T12055a.hs @@ -3,9 +3,9 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE FlexibleInstances, UndecidableInstances, FunctionalDependencies #-} diff --git a/testsuite/tests/polykinds/T12593.hs b/testsuite/tests/polykinds/T12593.hs index 867fb89284..8fd4f26578 100644 --- a/testsuite/tests/polykinds/T12593.hs +++ b/testsuite/tests/polykinds/T12593.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, ConstraintKinds, PolyKinds, TypeInType, KindSignatures, RankNTypes #-} +{-# LANGUAGE GADTs, ConstraintKinds, PolyKinds, KindSignatures, RankNTypes #-} module T12593 where diff --git a/testsuite/tests/polykinds/T12668.hs b/testsuite/tests/polykinds/T12668.hs index 4640903cc5..c3d2902a25 100644 --- a/testsuite/tests/polykinds/T12668.hs +++ b/testsuite/tests/polykinds/T12668.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} module T12668 where diff --git a/testsuite/tests/polykinds/T12718.hs b/testsuite/tests/polykinds/T12718.hs index 82d6dcd177..7bbe1d572e 100644 --- a/testsuite/tests/polykinds/T12718.hs +++ b/testsuite/tests/polykinds/T12718.hs @@ -1,5 +1,5 @@ {-# Language RebindableSyntax, NoImplicitPrelude, MagicHash, RankNTypes, - PolyKinds, ViewPatterns, TypeInType, FlexibleInstances #-} + PolyKinds, ViewPatterns, FlexibleInstances #-} module Main where diff --git a/testsuite/tests/polykinds/T13391.hs b/testsuite/tests/polykinds/T13391.hs deleted file mode 100644 index 6de3c3aa40..0000000000 --- a/testsuite/tests/polykinds/T13391.hs +++ /dev/null @@ -1,7 +0,0 @@ -{-# LANGUAGE PolyKinds, GADTs #-} - -module T13391 where - -data G (a :: k) where - GInt :: G Int - GMaybe :: G Maybe diff --git a/testsuite/tests/polykinds/T13391.stderr b/testsuite/tests/polykinds/T13391.stderr deleted file mode 100644 index 55fff35b3a..0000000000 --- a/testsuite/tests/polykinds/T13391.stderr +++ /dev/null @@ -1,7 +0,0 @@ - -T13391.hs:6:3: error: - • Data constructor ‘GInt’ constrains the choice of kind parameter: - k ~ * - Use TypeInType to allow this - • In the definition of data constructor ‘GInt’ - In the data type declaration for ‘G’ diff --git a/testsuite/tests/polykinds/T13625.hs b/testsuite/tests/polykinds/T13625.hs index 62d34611be..9367aa694f 100644 --- a/testsuite/tests/polykinds/T13625.hs +++ b/testsuite/tests/polykinds/T13625.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T13625 where diff --git a/testsuite/tests/polykinds/T13659.hs b/testsuite/tests/polykinds/T13659.hs index 199ff08a8d..118a04f122 100644 --- a/testsuite/tests/polykinds/T13659.hs +++ b/testsuite/tests/polykinds/T13659.hs @@ -4,8 +4,10 @@ module T13659 where +import Data.Kind (Type) + -- format string parameterized by a list of types -data Format (fmt :: [*]) where +data Format (fmt :: [Type]) where X :: Format '[] -- empty string, i.e. "" L :: a -> String -> Format '[] -- string literal, e.g. "hello" S :: a -> Format '[String] -- "%s" diff --git a/testsuite/tests/polykinds/T13659.stderr b/testsuite/tests/polykinds/T13659.stderr index fac5cbb952..84e81d04c0 100644 --- a/testsuite/tests/polykinds/T13659.stderr +++ b/testsuite/tests/polykinds/T13659.stderr @@ -1,5 +1,5 @@ -T13659.hs:12:27: error: +T13659.hs:14:27: error: • Expected a type, but ‘a’ has kind ‘[*]’ • In the first argument of ‘Format’, namely ‘'[Int, a]’ In the type ‘Format '[Int, a]’ diff --git a/testsuite/tests/polykinds/T13738.hs b/testsuite/tests/polykinds/T13738.hs index 85a1048f53..8420ca9158 100644 --- a/testsuite/tests/polykinds/T13738.hs +++ b/testsuite/tests/polykinds/T13738.hs @@ -1,9 +1,9 @@ {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} + module T13738 where import Data.Coerce diff --git a/testsuite/tests/polykinds/T13985.stderr b/testsuite/tests/polykinds/T13985.stderr index ec829dec4d..f60314a443 100644 --- a/testsuite/tests/polykinds/T13985.stderr +++ b/testsuite/tests/polykinds/T13985.stderr @@ -3,21 +3,21 @@ T13985.hs:12:1: error: • Kind variable ‘k’ is implicitly bound in data family ‘Fam’, but does not appear as the kind of any of its type variables. Perhaps you meant - to bind it (with TypeInType) explicitly somewhere? + to bind it explicitly somewhere? • In the data instance declaration for ‘Fam’ T13985.hs:15:15: error: • Kind variable ‘a’ is implicitly bound in type family ‘T’, but does not appear as the kind of any of its type variables. Perhaps you meant - to bind it (with TypeInType) explicitly somewhere? + to bind it explicitly somewhere? • In the type instance declaration for ‘T’ T13985.hs:22:3: error: • Kind variable ‘k’ is implicitly bound in associated data family ‘CD’, but does not appear as the kind of any of its type variables. Perhaps you meant - to bind it (with TypeInType) explicitly somewhere? + to bind it explicitly somewhere? • In the data instance declaration for ‘CD’ In the instance declaration for ‘C Type’ @@ -25,7 +25,7 @@ T13985.hs:23:8: error: • Kind variable ‘a’ is implicitly bound in associated type family ‘CT’, but does not appear as the kind of any of its type variables. Perhaps you meant - to bind it (with TypeInType) explicitly somewhere? + to bind it explicitly somewhere? • In the type instance declaration for ‘CT’ In the instance declaration for ‘C Type’ @@ -33,7 +33,7 @@ T13985.hs:27:3: error: • Kind variable ‘x’ is implicitly bound in associated type family ‘ZT’, but does not appear as the kind of any of its type variables. Perhaps you meant - to bind it (with TypeInType) explicitly somewhere? + to bind it explicitly somewhere? Type variables with inferred kinds: (k :: *) (a :: k) • In the default type instance declaration for ‘ZT’ In the class declaration for ‘Z’ diff --git a/testsuite/tests/polykinds/T14174.hs b/testsuite/tests/polykinds/T14174.hs index 7a58b70fc6..3fe4996225 100644 --- a/testsuite/tests/polykinds/T14174.hs +++ b/testsuite/tests/polykinds/T14174.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, RankNTypes, KindSignatures, PolyKinds #-} +{-# LANGUAGE RankNTypes, KindSignatures, PolyKinds #-} module T14174 where data T k (x :: k) = MkT diff --git a/testsuite/tests/polykinds/T14174a.hs b/testsuite/tests/polykinds/T14174a.hs index 82f418bc9d..bdd3d7ee88 100644 --- a/testsuite/tests/polykinds/T14174a.hs +++ b/testsuite/tests/polykinds/T14174a.hs @@ -1,14 +1,15 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} module T14174a where import Data.Kind -data TyFun :: * -> * -> * -type a ~> b = TyFun a b -> * +data TyFun :: Type -> Type -> Type +type a ~> b = TyFun a b -> Type infixr 0 ~> type family Apply (f :: k1 ~> k2) (x :: k1) :: k2 diff --git a/testsuite/tests/polykinds/T14209.hs b/testsuite/tests/polykinds/T14209.hs index 3e0181c4ed..0f0648bd79 100644 --- a/testsuite/tests/polykinds/T14209.hs +++ b/testsuite/tests/polykinds/T14209.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T14209 where data MyProxy k (a :: k) = MyProxy diff --git a/testsuite/tests/polykinds/T14270.hs b/testsuite/tests/polykinds/T14270.hs index 2d11a29993..3eed83c657 100644 --- a/testsuite/tests/polykinds/T14270.hs +++ b/testsuite/tests/polykinds/T14270.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE TypeInType #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE RankNTypes #-} @@ -8,6 +7,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeApplications #-} +{-# LANGUAGE PolyKinds #-} module T14270 (pattern App) where import Data.Kind (Type) diff --git a/testsuite/tests/polykinds/T14450.hs b/testsuite/tests/polykinds/T14450.hs index 3b8f5b7e70..8571829619 100644 --- a/testsuite/tests/polykinds/T14450.hs +++ b/testsuite/tests/polykinds/T14450.hs @@ -1,4 +1,6 @@ -{-# Language KindSignatures, TypeOperators, PolyKinds, TypeOperators, ConstraintKinds, TypeFamilies, DataKinds, TypeInType, GADTs, AllowAmbiguousTypes, InstanceSigs #-} +{-# Language KindSignatures, TypeOperators, PolyKinds, TypeOperators, + ConstraintKinds, TypeFamilies, DataKinds, GADTs, + AllowAmbiguousTypes, InstanceSigs #-} module T14450 where diff --git a/testsuite/tests/polykinds/T14450.stderr b/testsuite/tests/polykinds/T14450.stderr index c7caf04220..e8ff4aeae3 100644 --- a/testsuite/tests/polykinds/T14450.stderr +++ b/testsuite/tests/polykinds/T14450.stderr @@ -1,5 +1,5 @@ -T14450.hs:31:12: error: +T14450.hs:33:12: error: • Expected kind ‘k ~> k’, but ‘(IddSym0 :: Type ~> Type)’ has kind ‘* ~> *’ • In the first argument of ‘Dom’, namely diff --git a/testsuite/tests/polykinds/T14515.hs b/testsuite/tests/polykinds/T14515.hs index 15bdbfe31d..4a2540b925 100644 --- a/testsuite/tests/polykinds/T14515.hs +++ b/testsuite/tests/polykinds/T14515.hs @@ -1,5 +1,6 @@ {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} module Bug where import Data.Kind diff --git a/testsuite/tests/polykinds/T14520.hs b/testsuite/tests/polykinds/T14520.hs index ed87035b24..23e903773b 100644 --- a/testsuite/tests/polykinds/T14520.hs +++ b/testsuite/tests/polykinds/T14520.hs @@ -1,4 +1,4 @@ -{-# Language TypeInType, TypeFamilies, TypeOperators #-} +{-# Language DataKinds, PolyKinds, TypeFamilies, TypeOperators #-} module T14520 where @@ -10,7 +10,7 @@ data family Sing (a::k) type family XXX (f::a~>>b) (x::a) :: b -type family Id :: (kat :: a ~>> (a ~>> *)) `XXX` (b :: a) `XXX` b +type family Id :: (kat :: a ~>> (a ~>> Type)) `XXX` (b :: a) `XXX` b sId :: Sing w -> Sing (Id :: bat w w) sId = sId diff --git a/testsuite/tests/polykinds/T14555.hs b/testsuite/tests/polykinds/T14555.hs index 0ab71b1b76..7f37a5ec9c 100644 --- a/testsuite/tests/polykinds/T14555.hs +++ b/testsuite/tests/polykinds/T14555.hs @@ -1,10 +1,10 @@ -{-# Language TypeInType #-} {-# Language TypeOperators, DataKinds, PolyKinds, GADTs #-} + module T14555 where import Data.Kind -import GHC.Types (TYPE) +import GHC.Types (TYPE, Type) data Exp :: [TYPE rep] -> TYPE rep -> Type where --data Exp (x :: [TYPE rep]) (y :: TYPE rep) where diff --git a/testsuite/tests/polykinds/T14561.hs b/testsuite/tests/polykinds/T14561.hs index f528e7c813..7b1f17e08e 100644 --- a/testsuite/tests/polykinds/T14561.hs +++ b/testsuite/tests/polykinds/T14561.hs @@ -1,5 +1,5 @@ -{-# LANGUAGE TypeInType #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE MagicHash #-} diff --git a/testsuite/tests/polykinds/T14563.hs b/testsuite/tests/polykinds/T14563.hs index bedc99f54b..bdc05dd6df 100644 --- a/testsuite/tests/polykinds/T14563.hs +++ b/testsuite/tests/polykinds/T14563.hs @@ -1,6 +1,6 @@ -{-# Language TypeInType #-} {-# Language RankNTypes, KindSignatures, PolyKinds #-} {-# OPTIONS_GHC -fprint-explicit-runtime-reps #-} + import GHC.Types (TYPE) import Data.Kind diff --git a/testsuite/tests/polykinds/T14580.hs b/testsuite/tests/polykinds/T14580.hs index 6d11d78dfe..58983cc117 100644 --- a/testsuite/tests/polykinds/T14580.hs +++ b/testsuite/tests/polykinds/T14580.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE PolyKinds, DataKinds, TypeInType, TypeOperators #-} +{-# LANGUAGE PolyKinds, DataKinds, TypeOperators #-} module T14580 where import Data.Kind diff --git a/testsuite/tests/polykinds/T14710.stderr b/testsuite/tests/polykinds/T14710.stderr index 8d8a9785a8..0bbfb0d641 100644 --- a/testsuite/tests/polykinds/T14710.stderr +++ b/testsuite/tests/polykinds/T14710.stderr @@ -20,19 +20,11 @@ T14710.hs:18:24: error: In the type signature for ‘g2’ T14710.hs:21:31: error: - Variable ‘k’ used as both a kind and a type - Did you intend to use TypeInType? - -T14710.hs:21:31: error: Unexpected kind variable ‘k’ Perhaps you intended to use PolyKinds In the type signature for ‘h1’ T14710.hs:24:22: error: - Variable ‘k’ used as both a kind and a type - Did you intend to use TypeInType? - -T14710.hs:24:22: error: Unexpected kind variable ‘k’ Perhaps you intended to use PolyKinds In the type signature for ‘h2’ diff --git a/testsuite/tests/polykinds/T14846.hs b/testsuite/tests/polykinds/T14846.hs index 7b96e942f3..0f70962562 100644 --- a/testsuite/tests/polykinds/T14846.hs +++ b/testsuite/tests/polykinds/T14846.hs @@ -6,7 +6,7 @@ {-# LANGUAGE InstanceSigs #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module T14846 where import Data.Kind diff --git a/testsuite/tests/polykinds/T14873.hs b/testsuite/tests/polykinds/T14873.hs index 6bb66ec640..9450a019bc 100644 --- a/testsuite/tests/polykinds/T14873.hs +++ b/testsuite/tests/polykinds/T14873.hs @@ -2,8 +2,9 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} module T14873 where import Data.Kind (Type) diff --git a/testsuite/tests/polykinds/T15170.hs b/testsuite/tests/polykinds/T15170.hs index a105ca5344..02de90ae12 100644 --- a/testsuite/tests/polykinds/T15170.hs +++ b/testsuite/tests/polykinds/T15170.hs @@ -1,7 +1,7 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T15170 where diff --git a/testsuite/tests/polykinds/T5716.hs b/testsuite/tests/polykinds/T5716.hs index 1b705a36b1..217e4c399a 100644 --- a/testsuite/tests/polykinds/T5716.hs +++ b/testsuite/tests/polykinds/T5716.hs @@ -4,10 +4,11 @@ module T5716 where +import Data.Kind (Type) data family DF a data instance DF Int = DFInt data U = U1 (DF Int) -data I :: U -> * where I1 :: I (U1 DFInt) +data I :: U -> Type where I1 :: I (U1 DFInt) diff --git a/testsuite/tests/polykinds/T5716.stderr b/testsuite/tests/polykinds/T5716.stderr index 0e3596da32..41bf517339 100644 --- a/testsuite/tests/polykinds/T5716.stderr +++ b/testsuite/tests/polykinds/T5716.stderr @@ -1,7 +1,7 @@ -T5716.hs:13:33: error: - • Data constructor ‘U1’ cannot be used here - (perhaps you intended to use TypeInType) - • In the first argument of ‘I’, namely ‘(U1 DFInt)’ +T5716.hs:14:39: error: + • Data constructor ‘DFInt’ cannot be used here + (it comes from a data family instance) + • In the first argument of ‘U1’, namely ‘DFInt’ + In the first argument of ‘I’, namely ‘(U1 DFInt)’ In the type ‘I (U1 DFInt)’ - In the definition of data constructor ‘I1’ diff --git a/testsuite/tests/polykinds/T6021.stderr b/testsuite/tests/polykinds/T6021.stderr deleted file mode 100644 index d747043d27..0000000000 --- a/testsuite/tests/polykinds/T6021.stderr +++ /dev/null @@ -1,4 +0,0 @@ - -T6021.hs:5:22: error: - Variable ‘b’ used as both a kind and a type - Did you intend to use TypeInType? diff --git a/testsuite/tests/polykinds/T6035.hs b/testsuite/tests/polykinds/T6035.hs index a6f5ffe54a..c89de8e73d 100644 --- a/testsuite/tests/polykinds/T6035.hs +++ b/testsuite/tests/polykinds/T6035.hs @@ -3,9 +3,11 @@ module T6035 where +import Data.Kind (Type) + data Nat = Zero | Succ Nat -type family Sing (a :: k) :: k -> * +type family Sing (a :: k) :: k -> Type data SNat n where SZero :: SNat Zero diff --git a/testsuite/tests/polykinds/T6039.stderr b/testsuite/tests/polykinds/T6039.stderr index 048efd538f..bcaa2e1b4c 100644 --- a/testsuite/tests/polykinds/T6039.stderr +++ b/testsuite/tests/polykinds/T6039.stderr @@ -1,4 +1,10 @@ -T6039.hs:5:14: error: - • Expected kind ‘* -> *’, but ‘j’ has kind ‘*’ - • In the kind ‘j k’ +T6039.hs:5:1: error: + You have written a *complete user-suppled kind signature*, + but the following variable is undetermined: k0 :: * + Perhaps add a kind signature. + Inferred kinds of user-written variables: + j :: k0 -> * + k :: k0 + a :: j k + Inferred result kind: * diff --git a/testsuite/tests/polykinds/T6093.hs b/testsuite/tests/polykinds/T6093.hs index 3fdeb207f8..1063b8661d 100644 --- a/testsuite/tests/polykinds/T6093.hs +++ b/testsuite/tests/polykinds/T6093.hs @@ -1,13 +1,12 @@ -{-# LANGUAGE GADTs, PolyKinds #-} +{-# LANGUAGE GADTs, RankNTypes, PolyKinds #-} module T6093 where -- Polymorphic kind recursion -data R :: k -> * where +data R :: forall k. k -> * where MkR :: R f -> R (f ()) - data IOWitness (a :: k) = IOW -data Type :: k -> * where +data Type :: forall k. k -> * where SimpleType :: IOWitness a -> Type a ConstructedType :: Type f -> Type a -> Type (f a) diff --git a/testsuite/tests/polykinds/T7404.stderr b/testsuite/tests/polykinds/T7404.stderr deleted file mode 100644 index abae5a6215..0000000000 --- a/testsuite/tests/polykinds/T7404.stderr +++ /dev/null @@ -1,4 +0,0 @@ - -T7404.hs:4:32: error: - Variable ‘x’ used as both a kind and a type - Did you intend to use TypeInType? diff --git a/testsuite/tests/polykinds/T7594.hs b/testsuite/tests/polykinds/T7594.hs index ae21956d45..925b3f9ace 100644 --- a/testsuite/tests/polykinds/T7594.hs +++ b/testsuite/tests/polykinds/T7594.hs @@ -10,9 +10,11 @@ module T7594 where -import GHC.Exts (Constraint) +import Data.Kind (Constraint, Type) -class (c1 t, c2 t) => (:&:) (c1 :: * -> Constraint) (c2 :: * -> Constraint) (t :: *) +class (c1 t, c2 t) => (:&:) (c1 :: Type -> Constraint) + (c2 :: Type -> Constraint) + (t :: Type) instance (c1 t, c2 t) => (:&:) c1 c2 t data ColD c where diff --git a/testsuite/tests/polykinds/T7594.stderr b/testsuite/tests/polykinds/T7594.stderr index 3ea08a3fb8..1b4b9017f7 100644 --- a/testsuite/tests/polykinds/T7594.stderr +++ b/testsuite/tests/polykinds/T7594.stderr @@ -1,17 +1,18 @@ -T7594.hs:35:12: error: +T7594.hs:37:12: error: • Couldn't match type ‘b’ with ‘IO ()’ ‘b’ is untouchable inside the constraints: (:&:) c0 Real a bound by a type expected by the context: forall a. (:&:) c0 Real a => a -> b - at T7594.hs:35:8-19 + at T7594.hs:37:8-19 ‘b’ is a rigid type variable bound by - the inferred type of bar2 :: b at T7594.hs:35:1-19 + the inferred type of bar2 :: b + at T7594.hs:37:1-19 Possible fix: add a type signature for ‘bar2’ Expected type: a -> b Actual type: a -> IO () • In the first argument of ‘app’, namely ‘print’ In the expression: app print q2 In an equation for ‘bar2’: bar2 = app print q2 - • Relevant bindings include bar2 :: b (bound at T7594.hs:35:1) + • Relevant bindings include bar2 :: b (bound at T7594.hs:37:1) diff --git a/testsuite/tests/polykinds/T8566.hs b/testsuite/tests/polykinds/T8566.hs index 248febb586..2ffdecfd6e 100644 --- a/testsuite/tests/polykinds/T8566.hs +++ b/testsuite/tests/polykinds/T8566.hs @@ -10,10 +10,12 @@ module T8566 where -data U (s :: *) = forall v. AA v [U s] +import Data.Kind (Type) + +data U (s :: Type) = forall v. AA v [U s] -- AA :: forall (s:*) (v:*). v -> [U s] -> U s -data I (u :: U *) (r :: [*]) :: * where +data I (u :: U Type) (r :: [Type]) :: Type where A :: I (AA t as) r -- Existential k -- A :: forall (u:U *) (r:[*]) Universal @@ -22,7 +24,7 @@ data I (u :: U *) (r :: [*]) :: * where -- I u r -- fs unused, but needs to be present for the bug -class C (u :: U *) (r :: [*]) (fs :: [*]) where +class C (u :: U Type) (r :: [Type]) (fs :: [Type]) where c :: I u r -> I u r -- c :: forall (u :: U *) (r :: [*]) (fs :: [*]). C u r fs => I u r -> I u r diff --git a/testsuite/tests/polykinds/T8566.stderr b/testsuite/tests/polykinds/T8566.stderr index d368d055f0..23dddf66c7 100644 --- a/testsuite/tests/polykinds/T8566.stderr +++ b/testsuite/tests/polykinds/T8566.stderr @@ -1,18 +1,18 @@ -T8566.hs:32:9: error: +T8566.hs:34:9: error: • Could not deduce (C ('AA (t (I a ps)) as) ps fs0) arising from a use of ‘c’ from the context: C ('AA (t (I a ps)) as) ps fs - bound by the instance declaration at T8566.hs:30:10-67 + bound by the instance declaration at T8566.hs:32:10-67 or from: 'AA t (a : as) ~ 'AA t1 as1 bound by a pattern with constructor: A :: forall v (t :: v) (as :: [U *]) (r :: [*]). I ('AA t as) r, in an equation for ‘c’ - at T8566.hs:32:5 + at T8566.hs:34:5 The type variable ‘fs0’ is ambiguous Relevant bindings include c :: I ('AA t (a : as)) ps -> I ('AA t (a : as)) ps - (bound at T8566.hs:32:3) + (bound at T8566.hs:34:3) • In the expression: c undefined In an equation for ‘c’: c A = c undefined In the instance declaration for ‘C ('AA t (a : as)) ps fs’ diff --git a/testsuite/tests/polykinds/T8566a.hs b/testsuite/tests/polykinds/T8566a.hs index 3d20c3e27d..22b628553f 100644 --- a/testsuite/tests/polykinds/T8566a.hs +++ b/testsuite/tests/polykinds/T8566a.hs @@ -6,13 +6,15 @@ {-# LANGUAGE TypeOperators #-} module T8566a where +import Data.Kind (Type) + data Field = forall k. APP k [Field] -data InField (u :: Field) :: * where +data InField (u :: Field) :: Type where A :: AppVars t (ExpandField args) -> InField (APP t args) -type family ExpandField (args :: [Field]) :: [*] -type family AppVars (t :: k) (vs :: [*]) :: * +type family ExpandField (args :: [Field]) :: [Type] +type family AppVars (t :: k) (vs :: [Type]) :: Type -- This function fails to compile, because we discard -- 'given' kind equalities. See comment 7 in Trac #8566 diff --git a/testsuite/tests/polykinds/T8985.hs b/testsuite/tests/polykinds/T8985.hs index 28a354be27..d9e8d2c66a 100644 --- a/testsuite/tests/polykinds/T8985.hs +++ b/testsuite/tests/polykinds/T8985.hs @@ -1,12 +1,14 @@ {-# LANGUAGE DataKinds, PolyKinds, TypeFamilies, GADTs, TypeOperators #-} -module T8905 where +module T8985 where + +import Data.Kind (Type) data X (xs :: [k]) = MkX -data Y :: (k -> *) -> [k] -> * where +data Y :: (k -> Type) -> [k] -> Type where MkY :: f x -> Y f (x ': xs) -type family F (a :: [[*]]) :: * +type family F (a :: [[Type]]) :: Type type instance F xss = Y X xss works :: Y X '[ '[ ] ] -> () diff --git a/testsuite/tests/polykinds/T9222.hs b/testsuite/tests/polykinds/T9222.hs index 8e46ccb3c5..3af1458427 100644 --- a/testsuite/tests/polykinds/T9222.hs +++ b/testsuite/tests/polykinds/T9222.hs @@ -1,6 +1,7 @@ {-# LANGUAGE RankNTypes, GADTs, DataKinds, PolyKinds, TypeOperators, TypeFamilies #-} module T9222 where +import Data.Kind import Data.Proxy -- Nov 2014: actually the type of Want is ambiguous if we @@ -9,5 +10,5 @@ import Data.Proxy -- So this program is erroneous. (But the original ticket was -- a crash, and that's still fixed!) -data Want :: (i,j) -> * where +data Want :: (i,j) -> Type where Want :: (a ~ '(b,c) => Proxy b) -> Want a diff --git a/testsuite/tests/polykinds/T9222.stderr b/testsuite/tests/polykinds/T9222.stderr index 604cc1b7ec..be80a79198 100644 --- a/testsuite/tests/polykinds/T9222.stderr +++ b/testsuite/tests/polykinds/T9222.stderr @@ -1,16 +1,16 @@ -T9222.hs:13:3: error: +T9222.hs:14:3: error: • Couldn't match type ‘c0’ with ‘c’ ‘c0’ is untouchable inside the constraints: a ~ '(b0, c0) bound by the type of the constructor ‘Want’: (a ~ '(b0, c0)) => Proxy b0 - at T9222.hs:13:3-43 + at T9222.hs:14:3-43 ‘c’ is a rigid type variable bound by the type of the constructor ‘Want’: forall i1 j1 (a :: (i1, j1)) (b :: i1) (c :: j1). ((a ~ '(b, c)) => Proxy b) -> Want a - at T9222.hs:13:3-43 + at T9222.hs:14:3-43 • In the ambiguity check for ‘Want’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes In the definition of data constructor ‘Want’ diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index 4fe88b2385..c3250b7ffd 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -38,7 +38,7 @@ test('T6036', normal, compile, ['']) test('T6025', normal, run_command, ['$MAKE -s --no-print-directory T6025']) test('T6002', normal, compile, ['']) test('T6039', normal, compile_fail, ['']) -test('T6021', normal, compile_fail, ['']) +test('T6021', normal, compile, ['']) test('T6020a', normal, compile, ['']) test('T6044', normal, compile, ['']) test('T6054', normal, run_command, ['$MAKE -s --no-print-directory T6054']) @@ -74,7 +74,7 @@ test('T7341', normal, compile_fail,['']) test('T7422', normal, compile,['']) test('T7433', normal, compile_fail,['']) test('T7438', normal, run_command, ['$MAKE -s --no-print-directory T7438']) -test('T7404', normal, compile_fail,['']) +test('T7404', normal, compile,['']) test('T7502', normal, compile,['']) test('T7488', normal, compile,['']) test('T7594', normal, compile_fail,['']) @@ -170,7 +170,6 @@ test('BadKindVar', normal, compile_fail, ['']) test('T13738', normal, compile_fail, ['']) test('T14209', normal, compile, ['']) test('T14265', normal, compile_fail, ['']) -test('T13391', normal, compile_fail, ['']) test('T13391a', normal, compile, ['']) test('T14270', normal, compile, ['']) test('T14450', normal, compile_fail, ['']) diff --git a/testsuite/tests/printer/Ppr040.hs b/testsuite/tests/printer/Ppr040.hs index a9885a9d53..6fc7b09b15 100644 --- a/testsuite/tests/printer/Ppr040.hs +++ b/testsuite/tests/printer/Ppr040.hs @@ -1,5 +1,5 @@ {-# LANGUAGE TemplateHaskell, RankNTypes, TypeOperators, DataKinds, - PolyKinds, TypeFamilies, GADTs, TypeInType #-} + PolyKinds, TypeFamilies, GADTs, StarIsType #-} module RAE_T32a where diff --git a/testsuite/tests/printer/Ppr045.hs b/testsuite/tests/printer/Ppr045.hs index 73364982b4..b4843afc51 100644 --- a/testsuite/tests/printer/Ppr045.hs +++ b/testsuite/tests/printer/Ppr045.hs @@ -5,6 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} +{-# LANGUAGE StarIsType #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableSuperClasses #-} {-# OPTIONS_GHC -fwarn-incomplete-patterns -fwarn-overlapping-patterns #-} diff --git a/testsuite/tests/rename/should_fail/T11592.hs b/testsuite/tests/rename/should_fail/T11592.hs index b963cdf8ba..53714f1a68 100644 --- a/testsuite/tests/rename/should_fail/T11592.hs +++ b/testsuite/tests/rename/should_fail/T11592.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module Bug11592 where diff --git a/testsuite/tests/rename/should_fail/T13947.stderr b/testsuite/tests/rename/should_fail/T13947.stderr index 8a636a2bb9..8533f9f743 100644 --- a/testsuite/tests/rename/should_fail/T13947.stderr +++ b/testsuite/tests/rename/should_fail/T13947.stderr @@ -1,3 +1,3 @@ -T13947.hs:4:12: error: +T13947.hs:4:16: error: Not in scope: type constructor or class ‘:~:’ diff --git a/testsuite/tests/simplCore/should_compile/T13025a.hs b/testsuite/tests/simplCore/should_compile/T13025a.hs index 3f9a4cbe21..cdfb899c1a 100644 --- a/testsuite/tests/simplCore/should_compile/T13025a.hs +++ b/testsuite/tests/simplCore/should_compile/T13025a.hs @@ -4,17 +4,19 @@ TypeOperators #-} module T13025a where +import Data.Kind (Type) + data Nat = Z | S Nat data Proxy a = Proxy -data Field :: (k,*) -> * where +data Field :: (k,Type) -> Type where Field :: a -> Field '(s,a) type family Index r rs :: Nat where Index r (r ': rs) = 'Z Index r (s ': rs) = 'S (Index r rs) -data Rec (rs :: [ (k,*) ]) where +data Rec (rs :: [ (k,Type) ]) where Nil :: Rec '[] (:&) :: Field r -> Rec rs -> Rec (r ': rs) infixr 5 :& diff --git a/testsuite/tests/simplCore/should_compile/T13658.hs b/testsuite/tests/simplCore/should_compile/T13658.hs index 0890e89b7f..662fa66022 100644 --- a/testsuite/tests/simplCore/should_compile/T13658.hs +++ b/testsuite/tests/simplCore/should_compile/T13658.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RankNTypes #-} diff --git a/testsuite/tests/simplCore/should_compile/T14270a.hs b/testsuite/tests/simplCore/should_compile/T14270a.hs index 840b1e8436..5054b43a2c 100644 --- a/testsuite/tests/simplCore/should_compile/T14270a.hs +++ b/testsuite/tests/simplCore/should_compile/T14270a.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE TypeApplications, ScopedTypeVariables, GADTs, RankNTypes, TypeInType, KindSignatures #-} +{-# LANGUAGE TypeApplications, ScopedTypeVariables, GADTs, RankNTypes, + PolyKinds, KindSignatures #-} {-# OPTIONS_GHC -O2 #-} -- We are provoking a bug in SpecConstr module T14270a where diff --git a/testsuite/tests/simplCore/should_compile/T15186A.hs b/testsuite/tests/simplCore/should_compile/T15186A.hs index 472d01c0af..151fcec987 100644 --- a/testsuite/tests/simplCore/should_compile/T15186A.hs +++ b/testsuite/tests/simplCore/should_compile/T15186A.hs @@ -32,7 +32,7 @@ data BinomialTree (h::Height) (f :: k -> Type) :: Ctx k -> Type where -> !(BinomialTree ('Succ h) f x) -> BinomialTree h f x -newtype Assignment (f :: k -> *) (ctx :: Ctx k) +newtype Assignment (f :: k -> Type) (ctx :: Ctx k) = Assignment (BinomialTree 'Zero f ctx) data AssignView f ctx where diff --git a/testsuite/tests/simplCore/should_compile/T4903a.hs b/testsuite/tests/simplCore/should_compile/T4903a.hs index 8c8700038e..df6cb5bd32 100644 --- a/testsuite/tests/simplCore/should_compile/T4903a.hs +++ b/testsuite/tests/simplCore/should_compile/T4903a.hs @@ -8,18 +8,20 @@ module T4903a where +import Data.Kind + class El phi ix where proof :: phi ix class Fam phi where from :: phi ix -> ix -> PF phi I0 ix -type family PF (phi :: * -> *) :: (* -> *) -> * -> * +type family PF (phi :: Type -> Type) :: (Type -> Type) -> Type -> Type data I0 a = I0 a -data I xi (r :: * -> *) ix = I (r xi) -data (f :*: g) (r :: * -> *) ix = f r ix :*: g r ix +data I xi (r :: Type -> Type) ix = I (r xi) +data (f :*: g) (r :: Type -> Type) ix = f r ix :*: g r ix class HEq phi f where heq :: (forall ix. phi ix -> r ix -> Bool) @@ -45,7 +47,7 @@ tree :: Tree -- The problem only occurs on an inifite (or very large) structure tree = Bin tree tree -data TreeF :: * -> * where Tree :: TreeF Tree +data TreeF :: Type -> Type where Tree :: TreeF Tree type instance PF TreeF = I Tree :*: I Tree -- If the representation is only |I Tree| then there is no problem diff --git a/testsuite/tests/simplCore/should_run/T13750a.hs b/testsuite/tests/simplCore/should_run/T13750a.hs index 7ed72ca241..ac3806e7f9 100644 --- a/testsuite/tests/simplCore/should_run/T13750a.hs +++ b/testsuite/tests/simplCore/should_run/T13750a.hs @@ -6,14 +6,15 @@ {-# LANGUAGE ViewPatterns #-} module T13750a where +import Data.Kind (Type) import Unsafe.Coerce -type family AnyT :: * where {} -type family AnyList :: [*] where {} +type family AnyT :: Type where {} +type family AnyList :: [Type] where {} -newtype NP (xs :: [*]) = NP [AnyT] +newtype NP (xs :: [Type]) = NP [AnyT] -data IsNP (xs :: [*]) where +data IsNP (xs :: [Type]) where IsNil :: IsNP '[] IsCons :: x -> NP xs -> IsNP (x ': xs) @@ -34,9 +35,9 @@ pattern x :* xs <- (isNP -> IsCons x xs) x :* NP xs = NP (unsafeCoerce x : xs) infixr 5 :* -data NS (xs :: [[*]]) = NS !Int (NP AnyList) +data NS (xs :: [[Type]]) = NS !Int (NP AnyList) -data IsNS (xs :: [[*]]) where +data IsNS (xs :: [[Type]]) where IsZ :: NP x -> IsNS (x ': xs) IsS :: NS xs -> IsNS (x ': xs) diff --git a/testsuite/tests/th/T11463.hs b/testsuite/tests/th/T11463.hs index 1faf5964f4..3cb57d1cea 100644 --- a/testsuite/tests/th/T11463.hs +++ b/testsuite/tests/th/T11463.hs @@ -1,5 +1,5 @@ {-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module Main where import Data.Kind diff --git a/testsuite/tests/th/T11484.hs b/testsuite/tests/th/T11484.hs index d8c0708bd2..e1e30fc694 100644 --- a/testsuite/tests/th/T11484.hs +++ b/testsuite/tests/th/T11484.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T11484 where diff --git a/testsuite/tests/th/T13642.hs b/testsuite/tests/th/T13642.hs index 090b891433..ab655c0e4a 100644 --- a/testsuite/tests/th/T13642.hs +++ b/testsuite/tests/th/T13642.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GADTs, TypeInType, TemplateHaskell, RankNTypes #-} +{-# LANGUAGE GADTs, PolyKinds, TemplateHaskell, RankNTypes #-} module T13642 where import Data.Kind (Type) diff --git a/testsuite/tests/th/T13781.hs b/testsuite/tests/th/T13781.hs index 7498f56bae..2fd2f1a3d4 100644 --- a/testsuite/tests/th/T13781.hs +++ b/testsuite/tests/th/T13781.hs @@ -1,5 +1,5 @@ {-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T13781 where import Data.Kind diff --git a/testsuite/tests/th/T14060.hs b/testsuite/tests/th/T14060.hs index 5527b25b6e..8c4f2ddc95 100644 --- a/testsuite/tests/th/T14060.hs +++ b/testsuite/tests/th/T14060.hs @@ -2,7 +2,7 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilyDependencies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module Main where import Data.Kind diff --git a/testsuite/tests/th/T14869.hs b/testsuite/tests/th/T14869.hs index c58d4e2720..4b0dcdc171 100644 --- a/testsuite/tests/th/T14869.hs +++ b/testsuite/tests/th/T14869.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} module T14869 where import Data.Kind diff --git a/testsuite/tests/th/T8031.hs b/testsuite/tests/th/T8031.hs index 9f06c06ed6..08081ed6fd 100644 --- a/testsuite/tests/th/T8031.hs +++ b/testsuite/tests/th/T8031.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell, RankNTypes, TypeOperators, TypeInType, +{-# LANGUAGE TemplateHaskell, RankNTypes, TypeOperators, DataKinds, PolyKinds, GADTs #-} module T8031 where @@ -6,7 +6,7 @@ module T8031 where import Data.Proxy import Data.Kind -data SList :: [k] -> * where +data SList :: [k] -> Type where SCons :: Proxy h -> Proxy t -> SList (h ': t) $( [d| foo :: forall (a :: k). Proxy a diff --git a/testsuite/tests/th/TH_RichKinds2.hs b/testsuite/tests/th/TH_RichKinds2.hs index ab3e107d0f..9ac13a157b 100644 --- a/testsuite/tests/th/TH_RichKinds2.hs +++ b/testsuite/tests/th/TH_RichKinds2.hs @@ -8,6 +8,7 @@ module TH_RichKinds2 where +import qualified Data.Kind as K import Data.Char import Data.List import Language.Haskell.TH @@ -32,7 +33,7 @@ $( let fixKs :: String -> String -- need to remove TH renaming index from k vari if length index == 0 then s else prefix ++ "0" ++ (fixKs rest) in - do decls <- [d| data SMaybe :: (k -> *) -> (Maybe k) -> * where + do decls <- [d| data SMaybe :: (k -> K.Type) -> (Maybe k) -> K.Type where SNothing :: SMaybe s 'Nothing SJust :: s a -> SMaybe s ('Just a) @@ -42,7 +43,7 @@ $( let fixKs :: String -> String -- need to remove TH renaming index from k vari reportWarning (fixKs (pprint decls)) return decls ) -data SBool :: Bool -> * where +data SBool :: Bool -> K.Type where SFalse :: SBool 'False STrue :: SBool 'True diff --git a/testsuite/tests/th/TH_RichKinds2.stderr b/testsuite/tests/th/TH_RichKinds2.stderr index 6b0662218a..8970da8bdb 100644 --- a/testsuite/tests/th/TH_RichKinds2.stderr +++ b/testsuite/tests/th/TH_RichKinds2.stderr @@ -1,5 +1,5 @@ -TH_RichKinds2.hs:24:4: warning: +TH_RichKinds2.hs:25:4: warning: data SMaybe_0 :: (k_0 -> *) -> GHC.Base.Maybe k_0 -> * where SNothing_2 :: SMaybe_0 s_3 'GHC.Base.Nothing SJust_4 :: (s_5 a_6) -> SMaybe_0 s_5 ('GHC.Base.Just a_6) diff --git a/testsuite/tests/typecheck/should_compile/SplitWD.hs b/testsuite/tests/typecheck/should_compile/SplitWD.hs index 370b077b6e..5281cdbf0e 100644 --- a/testsuite/tests/typecheck/should_compile/SplitWD.hs +++ b/testsuite/tests/typecheck/should_compile/SplitWD.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ScopedTypeVariables, TypeInType, TypeOperators, +{-# LANGUAGE ScopedTypeVariables, TypeOperators, DataKinds, PolyKinds, TypeFamilies, GADTs, StandaloneDeriving #-} module SplitWD where diff --git a/testsuite/tests/typecheck/should_compile/T10432.hs b/testsuite/tests/typecheck/should_compile/T10432.hs index 7a9821e6cf..ec46f17f14 100644 --- a/testsuite/tests/typecheck/should_compile/T10432.hs +++ b/testsuite/tests/typecheck/should_compile/T10432.hs @@ -2,15 +2,16 @@ DataKinds, RankNTypes, GADTs, TypeOperators #-} module T10432 where +import Data.Kind (Type) import Data.Type.Equality data WrappedType = forall a. WrapType a; -matchReflK :: forall (a :: ka) (b :: kb) (r :: *). +matchReflK :: forall (a :: ka) (b :: kb) (r :: Type). ('WrapType a :~: 'WrapType b) -> (('WrapType a ~ 'WrapType b) => r) -> r; matchReflK Refl r = r; -matchReflK2 :: forall (a :: ka) (b :: kb) (r :: *). +matchReflK2 :: forall (a :: ka) (b :: kb) (r :: Type). ('WrapType a :~: 'WrapType b) -> r matchReflK2 x = let foo :: ('WrapType a ~ 'WrapType b) => r foo = undefined diff --git a/testsuite/tests/typecheck/should_compile/T11237.hs b/testsuite/tests/typecheck/should_compile/T11237.hs index 422aefdb67..db15a7b337 100644 --- a/testsuite/tests/typecheck/should_compile/T11237.hs +++ b/testsuite/tests/typecheck/should_compile/T11237.hs @@ -1,6 +1,6 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, KindSignatures #-} {-# LANGUAGE GADTs #-} -module TypeInTypeBug where +module T11237 where import qualified Data.Kind diff --git a/testsuite/tests/typecheck/should_compile/T11348.hs b/testsuite/tests/typecheck/should_compile/T11348.hs index 2548dbdab7..6edc0acd3e 100644 --- a/testsuite/tests/typecheck/should_compile/T11348.hs +++ b/testsuite/tests/typecheck/should_compile/T11348.hs @@ -2,7 +2,6 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE TypeInType #-} module T11348 where diff --git a/testsuite/tests/typecheck/should_compile/T11524.hs b/testsuite/tests/typecheck/should_compile/T11524.hs index d257554439..d6e2adf4f4 100644 --- a/testsuite/tests/typecheck/should_compile/T11524.hs +++ b/testsuite/tests/typecheck/should_compile/T11524.hs @@ -2,7 +2,6 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE PatternSynonyms #-} -{-# LANGUAGE TypeInType #-} module T11524 where diff --git a/testsuite/tests/typecheck/should_compile/T11723.hs b/testsuite/tests/typecheck/should_compile/T11723.hs index 1933024f2e..636e40fdb0 100644 --- a/testsuite/tests/typecheck/should_compile/T11723.hs +++ b/testsuite/tests/typecheck/should_compile/T11723.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module Example where import Data.Typeable diff --git a/testsuite/tests/typecheck/should_compile/T11811.hs b/testsuite/tests/typecheck/should_compile/T11811.hs index 16a225b4cf..a3fadb92e7 100644 --- a/testsuite/tests/typecheck/should_compile/T11811.hs +++ b/testsuite/tests/typecheck/should_compile/T11811.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, GADTs #-} +{-# LANGUAGE PolyKinds, GADTs #-} module T11811 where diff --git a/testsuite/tests/typecheck/should_compile/T12133.hs b/testsuite/tests/typecheck/should_compile/T12133.hs index f2502a786a..f35c51000d 100644 --- a/testsuite/tests/typecheck/should_compile/T12133.hs +++ b/testsuite/tests/typecheck/should_compile/T12133.hs @@ -11,10 +11,10 @@ module T12133 where import GHC.Classes (IP(..)) -import GHC.Exts (Constraint) +import Data.Kind (Constraint, Type) -- | From "Data.Constraint": -data Dict :: Constraint -> * where Dict :: a => Dict a +data Dict :: Constraint -> Type where Dict :: a => Dict a newtype a :- b = Sub (a => Dict b) @@ -65,4 +65,4 @@ t.hs:44:13: error: foo :: (c1, c2) :- c3 -> (c1, (IP sym ty, c2)) :- (IP sym ty, c3) (bound at t.hs:40:1) Failed, modules loaded: none. --}
\ No newline at end of file +-} diff --git a/testsuite/tests/typecheck/should_compile/T12381.hs b/testsuite/tests/typecheck/should_compile/T12381.hs index 9d4d731374..102a48321c 100644 --- a/testsuite/tests/typecheck/should_compile/T12381.hs +++ b/testsuite/tests/typecheck/should_compile/T12381.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, TypeFamilies #-} +{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies #-} module Kinds where import GHC.Types diff --git a/testsuite/tests/typecheck/should_compile/T12734.hs b/testsuite/tests/typecheck/should_compile/T12734.hs index a3b26d5aaf..e88d21a233 100644 --- a/testsuite/tests/typecheck/should_compile/T12734.hs +++ b/testsuite/tests/typecheck/should_compile/T12734.hs @@ -20,6 +20,7 @@ module T12734 where import Prelude +import Data.Kind import Control.Applicative import Control.Monad.Fix import Control.Monad.Trans.Identity @@ -30,14 +31,14 @@ import Control.Monad.IO.Class data A data B data Net -data Type +data Ty data Layer4 t l data TermStore -- Helpers: Stack -data Stack layers (t :: * -> *) where +data Stack layers (t :: Type -> Type) where SLayer :: t l -> Stack ls t -> Stack (l ': ls) t SNull :: Stack '[] t @@ -57,28 +58,35 @@ type TermStack t layers = Stack layers (Layer4 (Expr t layers)) class Monad m => Constructor m t instance ( Monad m, expr ~ Expr t layers, Constructor m (TermStack t layers) - ) => Constructor m (Layer4 expr Type) + ) => Constructor m (Layer4 expr Ty) --- HERE IS A FUNNY BEHAVIOR: the commented line raises context reduction stack overflow -test_gr :: ( Constructor m (TermStack t layers), Inferable A layers m, Inferable B t m - , bind ~ Expr t layers --- ) => m (Expr t layers) - ) => m bind +-- HERE IS A FUNNY BEHAVIOR: the commented line raises context reduction stack +-- overflow +test_gr :: + ( Constructor m (TermStack t layers), Inferable A layers m, Inferable B t m + , bind ~ Expr t layers +-- ) => m (Expr t layers) + ) => m bind test_gr = undefined -- Explicit information about a type which could be inferred -class Monad m => Inferable (cls :: *) (t :: k) m | cls m -> t +class Monad m => Inferable (cls :: Type) (t :: k) m | cls m -> t -newtype KnownTypex (cls :: *) (t :: k) (m :: * -> *) (a :: *) = KnownTypex (IdentityT m a) deriving (Show, Functor, Monad, MonadIO, MonadFix, MonadTrans, Applicative, Alternative) +newtype KnownTyx (cls :: Type) (t :: k) (m :: Type -> Type) (a :: Type) = + KnownTyx (IdentityT m a) + deriving (Show, Functor, Monad, MonadIO, MonadFix, MonadTrans, + Applicative, Alternative) -instance {-# OVERLAPPABLE #-} (t ~ t', Monad m) => Inferable cls t (KnownTypex cls t' m) -instance {-# OVERLAPPABLE #-} (Inferable cls t n, MonadTrans m, Monad (m n)) => Inferable cls t (m n) +instance {-# OVERLAPPABLE #-} (t ~ t', Monad m) => + Inferable cls t (KnownTyx cls t' m) +instance {-# OVERLAPPABLE #-} (Inferable cls t n, MonadTrans m, Monad (m n)) => + Inferable cls t (m n) -runInferenceTx :: forall cls t m a. KnownTypex cls t m a -> m a +runInferenceTx :: forall cls t m a. KnownTyx cls t m a -> m a runInferenceTx = undefined @@ -86,7 +94,7 @@ runInferenceTx = undefined -- running it test_ghc_err :: (MonadIO m, MonadFix m) - => m (Expr Net '[Type]) + => m (Expr Net '[Ty]) test_ghc_err = runInferenceTx @B @Net - $ runInferenceTx @A @'[Type] + $ runInferenceTx @A @'[Ty] $ (test_gr) diff --git a/testsuite/tests/typecheck/should_compile/T12734a.hs b/testsuite/tests/typecheck/should_compile/T12734a.hs index 3add59e648..5f1da8b818 100644 --- a/testsuite/tests/typecheck/should_compile/T12734a.hs +++ b/testsuite/tests/typecheck/should_compile/T12734a.hs @@ -21,6 +21,7 @@ module T12734a where import Prelude +import Data.Kind import Control.Applicative import Control.Monad.Fix import Control.Monad.Trans.Identity @@ -31,12 +32,12 @@ import Control.Monad.IO.Class data A data B data Net -data Type +data Ty data Layer4 t l data TermStore -data Stack lrs (t :: * -> *) where +data Stack lrs (t :: Type -> Type) where SLayer :: t l -> Stack ls t -> Stack (l ': ls) t SNull :: Stack '[] t @@ -44,7 +45,7 @@ instance ( Con m (t l) , Con m (Stack ls t)) => Con m (Stack (l ': ls) t) instance Monad m => Con m (Stack '[] t) instance ( expr ~ Expr t lrs - , Con m (TStk t lrs)) => Con m (Layer4 expr Type) + , Con m (TStk t lrs)) => Con m (Layer4 expr Ty) newtype Expr t lrs = Expr (TStk t lrs) @@ -63,18 +64,18 @@ test_gr :: forall m t lrs bind. test_gr = undefined -newtype KT (cls :: *) (t :: k) (m :: * -> *) (a :: *) +newtype KT (cls :: Type) (t :: k) (m :: Type -> Type) (a :: Type) = KT (IdentityT m a) -test_ghc_err :: KT A '[Type] IO (Expr Net '[Type]) +test_ghc_err :: KT A '[Ty] IO (Expr Net '[Ty]) -test_ghc_err = test_gr @(KT A '[Type] IO) @_ @'[Type] @(Expr Net '[Type]) +test_ghc_err = test_gr @(KT A '[Ty] IO) @_ @'[Ty] @(Expr Net '[Ty]) {- Works! -test_ghc_err = test_gr @(KT A '[Type] IO) +test_ghc_err = test_gr @(KT A '[Ty] IO) @Net - @'[Type] - @(Expr Net '[Type]) + @'[Ty] + @(Expr Net '[Ty]) -} {- Some notes. See comment:10 on Trac #12734 @@ -82,22 +83,22 @@ test_ghc_err = test_gr @(KT A '[Type] IO) [W] Con m (TStk t lrs) [W] Inferable A lrs m [W] bind ~ Expr t lrs -[W] m bind ~ KT A '[Type] IO (Expr Net '[Type]) +[W] m bind ~ KT A '[Ty] IO (Expr Net '[Ty]) -==> m := KT A '[Type] IO - bind := Expr Net '[Type] +==> m := KT A '[Ty] IO + bind := Expr Net '[Ty] t := Net - lrs := '[Type] + lrs := '[Ty] [W] Con m (TStk t lrs) = Con m (Stack lrs (Layer4 bind)) --> inline lrs -[W] Con m (Stack '[Type] (Layer4 bind)) +[W] Con m (Stack '[Ty] (Layer4 bind)) --> instance [W] Con m (Stack '[] bind) --> Monad m + -[W] Con m (Layer4 bind Type) +[W] Con m (Layer4 bind Ty) --> [W] bind ~ Expr t0 lrs0 [W] Con m (TStk t0 lrs0) diff --git a/testsuite/tests/typecheck/should_compile/T12734a.stderr b/testsuite/tests/typecheck/should_compile/T12734a.stderr index 737659fa57..8d777c6616 100644 --- a/testsuite/tests/typecheck/should_compile/T12734a.stderr +++ b/testsuite/tests/typecheck/should_compile/T12734a.stderr @@ -1,9 +1,8 @@ -T12734a.hs:71:16: error: - • No instance for (Monad (KT A '[Type] IO)) +T12734a.hs:72:16: error: + • No instance for (Monad (KT A '[Ty] IO)) arising from a use of ‘test_gr’ • In the expression: - test_gr @(KT A '[Type] IO) @_ @'[Type] @(Expr Net '[Type]) + test_gr @(KT A '[Ty] IO) @_ @'[Ty] @(Expr Net '[Ty]) In an equation for ‘test_ghc_err’: - test_ghc_err - = test_gr @(KT A '[Type] IO) @_ @'[Type] @(Expr Net '[Type]) + test_ghc_err = test_gr @(KT A '[Ty] IO) @_ @'[Ty] @(Expr Net '[Ty]) diff --git a/testsuite/tests/typecheck/should_compile/T12785a.hs b/testsuite/tests/typecheck/should_compile/T12785a.hs index 1e4d6a1b64..3c3fa9aba5 100644 --- a/testsuite/tests/typecheck/should_compile/T12785a.hs +++ b/testsuite/tests/typecheck/should_compile/T12785a.hs @@ -1,5 +1,5 @@ {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} module T12785a where diff --git a/testsuite/tests/typecheck/should_compile/T12911.hs b/testsuite/tests/typecheck/should_compile/T12911.hs index 88c2125f2b..af3af3c5f3 100644 --- a/testsuite/tests/typecheck/should_compile/T12911.hs +++ b/testsuite/tests/typecheck/should_compile/T12911.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE ExplicitForAll, TypeInType, GADTSyntax, +{-# LANGUAGE ExplicitForAll, PolyKinds, GADTSyntax, ExistentialQuantification #-} module T12911 where diff --git a/testsuite/tests/typecheck/should_compile/T12919.hs b/testsuite/tests/typecheck/should_compile/T12919.hs index 1f77c1c8de..778abfa1e7 100644 --- a/testsuite/tests/typecheck/should_compile/T12919.hs +++ b/testsuite/tests/typecheck/should_compile/T12919.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, TypeFamilies, GADTs, ConstraintKinds #-} +{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies, GADTs, ConstraintKinds #-} module T12919 where diff --git a/testsuite/tests/typecheck/should_compile/T12987.hs b/testsuite/tests/typecheck/should_compile/T12987.hs index 0997985601..3341272df9 100644 --- a/testsuite/tests/typecheck/should_compile/T12987.hs +++ b/testsuite/tests/typecheck/should_compile/T12987.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T12987 where diff --git a/testsuite/tests/typecheck/should_compile/T13083.hs b/testsuite/tests/typecheck/should_compile/T13083.hs index 220da0855a..e294052309 100644 --- a/testsuite/tests/typecheck/should_compile/T13083.hs +++ b/testsuite/tests/typecheck/should_compile/T13083.hs @@ -8,11 +8,12 @@ module T13083 where +import Data.Kind import GHC.Generics (Par1(..),(:*:)(..)) import GHC.Exts (coerce) -- Representation as free vector space -type family V (a :: *) :: * -> * +type family V (a :: Type) :: Type -> Type type instance V R = Par1 type instance V (a,b) = V a :*: V b @@ -59,7 +60,7 @@ foo = coerce -- with that of ‘Par1’ -- arising from a use of ‘coerce’ --- Note that Par1 has the wrong kind (* -> *) for V Par1 +-- Note that Par1 has the wrong kind (Type -> Type) for V Par1 -- Same error: -- diff --git a/testsuite/tests/typecheck/should_compile/T13333.hs b/testsuite/tests/typecheck/should_compile/T13333.hs index fba64cede0..5aca099c3b 100644 --- a/testsuite/tests/typecheck/should_compile/T13333.hs +++ b/testsuite/tests/typecheck/should_compile/T13333.hs @@ -4,7 +4,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeOperators #-} module T13333 where diff --git a/testsuite/tests/typecheck/should_compile/T13337.hs b/testsuite/tests/typecheck/should_compile/T13337.hs index 39808b4f13..3448d9448a 100644 --- a/testsuite/tests/typecheck/should_compile/T13337.hs +++ b/testsuite/tests/typecheck/should_compile/T13337.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, ScopedTypeVariables, TypeOperators, GADTs #-} +{-# LANGUAGE PolyKinds, ScopedTypeVariables, TypeOperators, GADTs #-} {-# OPTIONS_GHC -Wno-overlapping-patterns #-} -- don't want erroneous warning in test output -- if removing this doesn't change output, then -- remove it! diff --git a/testsuite/tests/typecheck/should_compile/T13343.hs b/testsuite/tests/typecheck/should_compile/T13343.hs index a00655d5ef..fcff9db1a4 100644 --- a/testsuite/tests/typecheck/should_compile/T13343.hs +++ b/testsuite/tests/typecheck/should_compile/T13343.hs @@ -1,5 +1,5 @@ {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module Bug where import GHC.Exts diff --git a/testsuite/tests/typecheck/should_compile/T13458.hs b/testsuite/tests/typecheck/should_compile/T13458.hs index 9b51378d65..ef1f568769 100644 --- a/testsuite/tests/typecheck/should_compile/T13458.hs +++ b/testsuite/tests/typecheck/should_compile/T13458.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE MagicHash, TypeInType, ScopedTypeVariables #-} +{-# LANGUAGE MagicHash, PolyKinds, ScopedTypeVariables #-} {-# OPTIONS_GHC -O #-} module T13458 where import GHC.Exts diff --git a/testsuite/tests/typecheck/should_compile/T13603.hs b/testsuite/tests/typecheck/should_compile/T13603.hs index d0c1975e04..bcbed465b0 100644 --- a/testsuite/tests/typecheck/should_compile/T13603.hs +++ b/testsuite/tests/typecheck/should_compile/T13603.hs @@ -1,4 +1,4 @@ -{-# Language PolyKinds, TypeInType, UndecidableInstances #-} +{-# Language PolyKinds, UndecidableInstances #-} module T13603 where import GHC.Exts (TYPE, RuntimeRep) diff --git a/testsuite/tests/typecheck/should_compile/T13643.hs b/testsuite/tests/typecheck/should_compile/T13643.hs index d7cf1342c8..68e7225bf8 100644 --- a/testsuite/tests/typecheck/should_compile/T13643.hs +++ b/testsuite/tests/typecheck/should_compile/T13643.hs @@ -2,7 +2,7 @@ {-# Language RankNTypes #-} {-# Language KindSignatures #-} {-# Language DataKinds #-} -{-# Language TypeInType #-} +{-# Language PolyKinds #-} {-# Language GADTs #-} import Data.Kind (Type) diff --git a/testsuite/tests/typecheck/should_compile/T13822.hs b/testsuite/tests/typecheck/should_compile/T13822.hs index 5837cc8081..88c14c2aff 100644 --- a/testsuite/tests/typecheck/should_compile/T13822.hs +++ b/testsuite/tests/typecheck/should_compile/T13822.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE GADTs, TypeOperators, PolyKinds, DataKinds, TypeFamilyDependencies, TypeInType, RankNTypes, LambdaCase, EmptyCase #-} +{-# LANGUAGE GADTs, TypeOperators, PolyKinds, DataKinds, + TypeFamilyDependencies, RankNTypes, LambdaCase, EmptyCase #-} module T13822 where diff --git a/testsuite/tests/typecheck/should_compile/T13871.hs b/testsuite/tests/typecheck/should_compile/T13871.hs index 319d949647..623923eaca 100644 --- a/testsuite/tests/typecheck/should_compile/T13871.hs +++ b/testsuite/tests/typecheck/should_compile/T13871.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} {-# LANGUAGE TypeOperators #-} module Foo where diff --git a/testsuite/tests/typecheck/should_compile/T13879.hs b/testsuite/tests/typecheck/should_compile/T13879.hs index 9708c1dd41..2e10c472fb 100644 --- a/testsuite/tests/typecheck/should_compile/T13879.hs +++ b/testsuite/tests/typecheck/should_compile/T13879.hs @@ -2,7 +2,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} {-# LANGUAGE TypeOperators #-} module Bug where diff --git a/testsuite/tests/typecheck/should_compile/T13915a.hs b/testsuite/tests/typecheck/should_compile/T13915a.hs index 484c9dedc0..355166b8a0 100644 --- a/testsuite/tests/typecheck/should_compile/T13915a.hs +++ b/testsuite/tests/typecheck/should_compile/T13915a.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module Bug where import T13915a_Foo diff --git a/testsuite/tests/typecheck/should_compile/T13915b.hs b/testsuite/tests/typecheck/should_compile/T13915b.hs index dd64b13d4f..8949a86f06 100644 --- a/testsuite/tests/typecheck/should_compile/T13915b.hs +++ b/testsuite/tests/typecheck/should_compile/T13915b.hs @@ -1,5 +1,5 @@ {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} module Foo where import Data.Typeable (Proxy(..), typeRep) diff --git a/testsuite/tests/typecheck/should_compile/T13943.hs b/testsuite/tests/typecheck/should_compile/T13943.hs index f40ee237e6..7889fe6a41 100644 --- a/testsuite/tests/typecheck/should_compile/T13943.hs +++ b/testsuite/tests/typecheck/should_compile/T13943.hs @@ -5,7 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds, DataKinds #-} {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE GADTs #-} diff --git a/testsuite/tests/typecheck/should_compile/T14441.hs b/testsuite/tests/typecheck/should_compile/T14441.hs index 047de1659f..a2c1aff9ef 100644 --- a/testsuite/tests/typecheck/should_compile/T14441.hs +++ b/testsuite/tests/typecheck/should_compile/T14441.hs @@ -1,6 +1,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE PolyKinds #-} module T14441 where import Data.Kind diff --git a/testsuite/tests/typecheck/should_compile/T14934a.hs b/testsuite/tests/typecheck/should_compile/T14934a.hs index 3ba59ff976..3a4865fffc 100644 --- a/testsuite/tests/typecheck/should_compile/T14934a.hs +++ b/testsuite/tests/typecheck/should_compile/T14934a.hs @@ -4,9 +4,10 @@ {-# LANGUAGE TypeOperators #-} module T14934a where +import Data.Kind (Type) import GHC.TypeLits -data Foo :: Nat -> * where +data Foo :: Nat -> Type where MkFoo0 :: Foo 0 MkFoo1 :: Foo 1 diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index f566182cc2..8a7a7da8ce 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -579,8 +579,8 @@ test('T13848', normal, compile, ['']) test('T13871', normal, compile, ['']) test('T13879', normal, compile, ['']) test('T13881', normal, compile, ['']) -test('T13915a', normal, multimod_compile, ['T13915a', '-v0']) -test('T13915b', normal, compile, ['']) +test('T13915a', expect_broken(15245), multimod_compile, ['T13915a', '-v0']) +test('T13915b', expect_broken(15245), compile, ['']) test('T13984', normal, compile, ['']) test('T14128', normal, multimod_compile, ['T14128Main', '-v0']) test('T14149', normal, compile_fail, ['']) diff --git a/testsuite/tests/typecheck/should_compile/tc191.hs b/testsuite/tests/typecheck/should_compile/tc191.hs index 403ec88da9..c7a7c3e4c6 100644 --- a/testsuite/tests/typecheck/should_compile/tc191.hs +++ b/testsuite/tests/typecheck/should_compile/tc191.hs @@ -1,4 +1,4 @@ - +{-# LANGUAGE RankNTypes #-} -- This only typechecks if forall-hoisting works ok when -- importing from an interface file. The type of Twins.gzipWithQ diff --git a/testsuite/tests/typecheck/should_compile/tc205.hs b/testsuite/tests/typecheck/should_compile/tc205.hs index 1fe2cc255f..e45660fb3a 100644 --- a/testsuite/tests/typecheck/should_compile/tc205.hs +++ b/testsuite/tests/typecheck/should_compile/tc205.hs @@ -4,7 +4,9 @@ module ShouldCompile where +import Data.Kind + infix 1 `DArrowX` -- (->) has precedence 0 -data DArrowX :: * -> * -> * where +data DArrowX :: Type -> Type -> Type where First :: a `DArrowX` a' -> (a,b) `DArrowX` (a',b) diff --git a/testsuite/tests/typecheck/should_compile/tc269.hs b/testsuite/tests/typecheck/should_compile/tc269.hs index 33151cebe8..3ac88ce8e9 100644 --- a/testsuite/tests/typecheck/should_compile/tc269.hs +++ b/testsuite/tests/typecheck/should_compile/tc269.hs @@ -1,6 +1,5 @@ {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module Tc269 where import GHC.Types diff --git a/testsuite/tests/typecheck/should_compile/valid_hole_fits_interactions.hs b/testsuite/tests/typecheck/should_compile/valid_hole_fits_interactions.hs index a2186e73a3..069e1f7384 100644 --- a/testsuite/tests/typecheck/should_compile/valid_hole_fits_interactions.hs +++ b/testsuite/tests/typecheck/should_compile/valid_hole_fits_interactions.hs @@ -1,5 +1,5 @@ {-# LANGUAGE GADTs #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} module ValidSubsInteractions where diff --git a/testsuite/tests/typecheck/should_fail/ClassOperator.hs b/testsuite/tests/typecheck/should_fail/ClassOperator.hs index 6d41d113fb..922cbdb0f4 100644 --- a/testsuite/tests/typecheck/should_fail/ClassOperator.hs +++ b/testsuite/tests/typecheck/should_fail/ClassOperator.hs @@ -2,9 +2,11 @@ module ClassOperator where +import Data.Kind + -- | Class with fixity, including associated types class a ><> b where - type a <>< b :: * + type a <>< b :: Type data a ><< b (>><), (<<>) :: a -> b -> () diff --git a/testsuite/tests/typecheck/should_fail/ClassOperator.stderr b/testsuite/tests/typecheck/should_fail/ClassOperator.stderr index bc4eb7c598..78017f22ba 100644 --- a/testsuite/tests/typecheck/should_fail/ClassOperator.stderr +++ b/testsuite/tests/typecheck/should_fail/ClassOperator.stderr @@ -1,10 +1,10 @@ -ClassOperator.hs:12:3: error: +ClassOperator.hs:14:3: error: • Could not deduce (a ><> b0) from the context: a ><> b bound by the type signature for: (**>) :: forall a b. (a ><> b) => a -> a -> () - at ClassOperator.hs:12:3-44 + at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous • In the ambiguity check for ‘**>’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes @@ -12,12 +12,12 @@ ClassOperator.hs:12:3: error: (**>) :: forall a b. (a ><> b) => a -> a -> () In the class declaration for ‘><>’ -ClassOperator.hs:12:3: error: +ClassOperator.hs:14:3: error: • Could not deduce (a ><> b0) from the context: a ><> b bound by the type signature for: (**<) :: forall a b. (a ><> b) => a -> a -> () - at ClassOperator.hs:12:3-44 + at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous • In the ambiguity check for ‘**<’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes @@ -25,12 +25,12 @@ ClassOperator.hs:12:3: error: (**<) :: forall a b. (a ><> b) => a -> a -> () In the class declaration for ‘><>’ -ClassOperator.hs:12:3: error: +ClassOperator.hs:14:3: error: • Could not deduce (a ><> b0) from the context: a ><> b bound by the type signature for: (>**) :: forall a b. (a ><> b) => a -> a -> () - at ClassOperator.hs:12:3-44 + at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous • In the ambiguity check for ‘>**’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes @@ -38,12 +38,12 @@ ClassOperator.hs:12:3: error: (>**) :: forall a b. (a ><> b) => a -> a -> () In the class declaration for ‘><>’ -ClassOperator.hs:12:3: error: +ClassOperator.hs:14:3: error: • Could not deduce (a ><> b0) from the context: a ><> b bound by the type signature for: (<**) :: forall a b. (a ><> b) => a -> a -> () - at ClassOperator.hs:12:3-44 + at ClassOperator.hs:14:3-44 The type variable ‘b0’ is ambiguous • In the ambiguity check for ‘<**’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes diff --git a/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.hs b/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.hs index d1957bf34b..298668f213 100644 --- a/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.hs +++ b/testsuite/tests/typecheck/should_fail/CustomTypeErrors04.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-} +{-# LANGUAGE DataKinds, TypeFamilies, UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-} -- The "bad case" in #11391 diff --git a/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.hs b/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.hs index 5a15b6f363..7d200faef6 100644 --- a/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.hs +++ b/testsuite/tests/typecheck/should_fail/CustomTypeErrors05.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, TypeFamilies, UndecidableInstances #-} +{-# LANGUAGE DataKinds, TypeFamilies, UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-} -- The "tricky case" in #11391 diff --git a/testsuite/tests/typecheck/should_fail/LevPolyBounded.hs b/testsuite/tests/typecheck/should_fail/LevPolyBounded.hs index 0607956784..0a68a69a38 100644 --- a/testsuite/tests/typecheck/should_fail/LevPolyBounded.hs +++ b/testsuite/tests/typecheck/should_fail/LevPolyBounded.hs @@ -1,6 +1,6 @@ -- inspired by comment:25 on #12708 -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module LevPolyBounded where diff --git a/testsuite/tests/typecheck/should_fail/T11313.hs b/testsuite/tests/typecheck/should_fail/T11313.hs index 86ac9582b8..68aa5b0f6c 100644 --- a/testsuite/tests/typecheck/should_fail/T11313.hs +++ b/testsuite/tests/typecheck/should_fail/T11313.hs @@ -2,8 +2,6 @@ module T11313 where -import Data.Kind - x = fmap @ (*) -- test error message output, which was quite silly before diff --git a/testsuite/tests/typecheck/should_fail/T11313.stderr b/testsuite/tests/typecheck/should_fail/T11313.stderr index 7a681d17aa..8697d3b6c7 100644 --- a/testsuite/tests/typecheck/should_fail/T11313.stderr +++ b/testsuite/tests/typecheck/should_fail/T11313.stderr @@ -1,6 +1,6 @@ -T11313.hs:7:12: error: +T11313.hs:5:13: error: • Expected kind ‘* -> *’, but ‘*’ has kind ‘*’ - • In the type ‘*’ - In the expression: fmap @* - In an equation for ‘x’: x = fmap @* + • In the type ‘(*)’ + In the expression: fmap @(*) + In an equation for ‘x’: x = fmap @(*) diff --git a/testsuite/tests/typecheck/should_fail/T11724.hs b/testsuite/tests/typecheck/should_fail/T11724.hs index df575bd9b5..23412e9df9 100644 --- a/testsuite/tests/typecheck/should_fail/T11724.hs +++ b/testsuite/tests/typecheck/should_fail/T11724.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T11724 where diff --git a/testsuite/tests/typecheck/should_fail/T11963.hs b/testsuite/tests/typecheck/should_fail/T11963.hs deleted file mode 100644 index c4f78aee29..0000000000 --- a/testsuite/tests/typecheck/should_fail/T11963.hs +++ /dev/null @@ -1,29 +0,0 @@ -{-# LANGUAGE GADTs, PolyKinds, RankNTypes #-} - -module T11963 where - --- this module should be rejected without TypeInType - -import Data.Proxy - --- see code in RnTypes.extract_hs_tv_bndrs which checks for these bad cases - - -- bndr_kvs vs body_tvs -data Typ k t where - Typ :: (forall (a :: k -> *). a t -> a t) -> Typ k t - - -- bndr_kvs vs acc_tvs -foo :: (forall (t :: k). Proxy t) -> Proxy k -foo _ = undefined - - -- locals vs body_kvs -bar :: forall k. forall (t :: k). Proxy t -bar = undefined - - -- body_kvs vs acc_tvs -quux :: (forall t. Proxy (t :: k)) -> Proxy k -quux _ = undefined - - -- body_tvs vs acc_kvs -blargh :: (forall a. a -> Proxy k) -> Proxy (t :: k) -blargh _ = undefined diff --git a/testsuite/tests/typecheck/should_fail/T11963.stderr b/testsuite/tests/typecheck/should_fail/T11963.stderr deleted file mode 100644 index bd1ae4dc76..0000000000 --- a/testsuite/tests/typecheck/should_fail/T11963.stderr +++ /dev/null @@ -1,20 +0,0 @@ - -T11963.hs:13:26: error: - Variable ‘k’ used as both a kind and a type - Did you intend to use TypeInType? - -T11963.hs:16:22: error: - Variable ‘k’ used as both a kind and a type - Did you intend to use TypeInType? - -T11963.hs:20:31: error: - Variable ‘k’ used as both a kind and a type - Did you intend to use TypeInType? - -T11963.hs:24:32: error: - Variable ‘k’ used as both a kind and a type - Did you intend to use TypeInType? - -T11963.hs:28:51: error: - Variable ‘k’ used as both a kind and a type - Did you intend to use TypeInType? diff --git a/testsuite/tests/typecheck/should_fail/T12648.hs b/testsuite/tests/typecheck/should_fail/T12648.hs index b36ecce3bc..b75bcf9226 100644 --- a/testsuite/tests/typecheck/should_fail/T12648.hs +++ b/testsuite/tests/typecheck/should_fail/T12648.hs @@ -13,7 +13,7 @@ {-# LANGUAGE UndecidableSuperClasses #-} module T12648 where -import GHC.Exts (Constraint) +import Data.Kind (Type, Constraint) import Unsafe.Coerce (unsafeCoerce) type family Skolem (p :: k -> Constraint) :: k @@ -25,7 +25,7 @@ instance p (Skolem p) => Forall_ (p :: k -> Constraint) inst :: forall p a. Forall p :- p a inst = unsafeCoerce (Sub Dict :: Forall p :- p (Skolem p)) -data Dict :: Constraint -> * where +data Dict :: Constraint -> Type where Dict :: a => Dict a newtype a :- b = Sub (a => Dict b) @@ -40,7 +40,7 @@ class (Applicative b, Applicative m, Monad b, Monad m) => MonadBase b m | m -> b instance MonadBase IO IO -- where liftBase = id class MonadBase b m => MonadBaseControl b m | m -> b where - type StM m a :: * + type StM m a :: Type liftBaseWith :: (RunInBase m b -> b a) -> m a type RunInBase m b = forall a. m a -> b (StM m a) diff --git a/testsuite/tests/typecheck/should_fail/T12709.hs b/testsuite/tests/typecheck/should_fail/T12709.hs index 2bbcf744d0..6a7e37a5d2 100644 --- a/testsuite/tests/typecheck/should_fail/T12709.hs +++ b/testsuite/tests/typecheck/should_fail/T12709.hs @@ -1,4 +1,5 @@ -{-# Language MagicHash, PolyKinds, ViewPatterns, TypeInType, RebindableSyntax, NoImplicitPrelude #-} +{-# Language PolyKinds, ViewPatterns, RebindableSyntax, + MagicHash, NoImplicitPrelude #-} module T12709 where diff --git a/testsuite/tests/typecheck/should_fail/T12709.stderr b/testsuite/tests/typecheck/should_fail/T12709.stderr index 7be861c061..9d79d8dd0c 100644 --- a/testsuite/tests/typecheck/should_fail/T12709.stderr +++ b/testsuite/tests/typecheck/should_fail/T12709.stderr @@ -1,23 +1,23 @@ -T12709.hs:27:13: error: +T12709.hs:28:13: error: A levity-polymorphic type is not allowed here: Type: a Kind: TYPE rep In the type of expression: 1 -T12709.hs:27:17: error: +T12709.hs:28:17: error: A levity-polymorphic type is not allowed here: Type: a Kind: TYPE rep In the type of expression: 2 -T12709.hs:27:21: error: +T12709.hs:28:21: error: A levity-polymorphic type is not allowed here: Type: a Kind: TYPE rep In the type of expression: 3 -T12709.hs:27:25: error: +T12709.hs:28:25: error: A levity-polymorphic type is not allowed here: Type: a Kind: TYPE rep diff --git a/testsuite/tests/typecheck/should_fail/T12785b.hs b/testsuite/tests/typecheck/should_fail/T12785b.hs index 4188e3e67c..b827372bf0 100644 --- a/testsuite/tests/typecheck/should_fail/T12785b.hs +++ b/testsuite/tests/typecheck/should_fail/T12785b.hs @@ -1,6 +1,6 @@ -{-# LANGUAGE RankNTypes, TypeInType, TypeOperators, KindSignatures, ViewPatterns #-} +{-# LANGUAGE RankNTypes, TypeOperators, ViewPatterns #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE DataKinds, GADTs #-} +{-# LANGUAGE DataKinds, PolyKinds, GADTs #-} module T12785b where @@ -13,14 +13,14 @@ data HTree n a where Leaf :: HTree (S n) a Branch :: a -> HTree n (HTree (S n) a) -> HTree (S n) a -data STree n :: forall a . (a -> *) -> HTree n a -> * where +data STree n :: forall a . (a -> Type) -> HTree n a -> Type where SPoint :: f a -> STree Z f (Point a) SLeaf :: STree (S n) f Leaf SBranch :: f a -> STree n (STree (S n) f) stru -> STree (S n) f (a `Branch` stru) SBranchX :: (Payload (S n) (Payload n stru) ~ a) => f a -> STree n (STree (S n) f) stru -> STree (S n) f (a `Branch` stru) -data Hidden :: Peano -> (a -> *) -> * where +data Hidden :: Peano -> (a -> Type) -> Type where Hide :: STree n f s -> Hidden n f nest :: HTree m (Hidden (S m) f) -> Hidden m (STree ('S m) f) diff --git a/testsuite/tests/typecheck/should_fail/T12973.hs b/testsuite/tests/typecheck/should_fail/T12973.hs index 624d24be24..b0a33a8213 100644 --- a/testsuite/tests/typecheck/should_fail/T12973.hs +++ b/testsuite/tests/typecheck/should_fail/T12973.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RebindableSyntax, TypeInType, ExplicitForAll #-} +{-# LANGUAGE RebindableSyntax, PolyKinds, ExplicitForAll #-} module T12973 where diff --git a/testsuite/tests/typecheck/should_fail/T13105.hs b/testsuite/tests/typecheck/should_fail/T13105.hs index 44384dc19d..b2b23c7442 100644 --- a/testsuite/tests/typecheck/should_fail/T13105.hs +++ b/testsuite/tests/typecheck/should_fail/T13105.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE UnicodeSyntax, MagicHash, TypeInType, TypeFamilies #-} +{-# LANGUAGE UnicodeSyntax, MagicHash, DataKinds, PolyKinds, TypeFamilies #-} -- from Conal Elliott -- Actually, this *should* work. But I want to put it in the testsuite diff --git a/testsuite/tests/typecheck/should_fail/T13446.hs b/testsuite/tests/typecheck/should_fail/T13446.hs index 11a60776f6..b5bd77fcb0 100644 --- a/testsuite/tests/typecheck/should_fail/T13446.hs +++ b/testsuite/tests/typecheck/should_fail/T13446.hs @@ -11,10 +11,10 @@ module T13446 where import Data.Coerce (Coercible) -import GHC.Exts (Constraint) +import Data.Kind (Type, Constraint) import GHC.TypeLits (Symbol) -data Dict :: Constraint -> * where +data Dict :: Constraint -> Type where Dict :: a => Dict a infixr 9 :- diff --git a/testsuite/tests/typecheck/should_fail/T13909.hs b/testsuite/tests/typecheck/should_fail/T13909.hs index 4f0cbdc8b1..58798d5f79 100644 --- a/testsuite/tests/typecheck/should_fail/T13909.hs +++ b/testsuite/tests/typecheck/should_fail/T13909.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T13909 where import Data.Kind diff --git a/testsuite/tests/typecheck/should_fail/T13929.hs b/testsuite/tests/typecheck/should_fail/T13929.hs index 10a7430eee..f0801e8e0e 100644 --- a/testsuite/tests/typecheck/should_fail/T13929.hs +++ b/testsuite/tests/typecheck/should_fail/T13929.hs @@ -1,6 +1,6 @@ {-# LANGUAGE MagicHash #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE DeriveGeneric #-} diff --git a/testsuite/tests/typecheck/should_fail/T13983.stderr b/testsuite/tests/typecheck/should_fail/T13983.stderr index 65ce607961..5c7a031654 100644 --- a/testsuite/tests/typecheck/should_fail/T13983.stderr +++ b/testsuite/tests/typecheck/should_fail/T13983.stderr @@ -3,6 +3,6 @@ T13983.hs:7:1: error: • Kind variable ‘k’ is implicitly bound in type synonym ‘Wat’, but does not appear as the kind of any of its type variables. Perhaps you meant - to bind it (with TypeInType) explicitly somewhere? + to bind it explicitly somewhere? Type variables with inferred kinds: (k :: *) • In the type declaration for ‘Wat’ diff --git a/testsuite/tests/typecheck/should_fail/T14350.hs b/testsuite/tests/typecheck/should_fail/T14350.hs index b3de40f647..9d96e4570e 100644 --- a/testsuite/tests/typecheck/should_fail/T14350.hs +++ b/testsuite/tests/typecheck/should_fail/T14350.hs @@ -5,7 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds, DataKinds #-} {-# LANGUAGE TypeOperators #-} module T14350 where diff --git a/testsuite/tests/typecheck/should_fail/T14904a.hs b/testsuite/tests/typecheck/should_fail/T14904a.hs index 654f5a6618..af4cf65a33 100644 --- a/testsuite/tests/typecheck/should_fail/T14904a.hs +++ b/testsuite/tests/typecheck/should_fail/T14904a.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T14904a where import Data.Kind diff --git a/testsuite/tests/typecheck/should_fail/T14904b.hs b/testsuite/tests/typecheck/should_fail/T14904b.hs index d8cfa1ea07..529b273245 100644 --- a/testsuite/tests/typecheck/should_fail/T14904b.hs +++ b/testsuite/tests/typecheck/should_fail/T14904b.hs @@ -1,6 +1,6 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} module T14904b where import Data.Kind diff --git a/testsuite/tests/typecheck/should_fail/T7645.hs b/testsuite/tests/typecheck/should_fail/T7645.hs index db086c8e61..b7a2af4ebd 100644 --- a/testsuite/tests/typecheck/should_fail/T7645.hs +++ b/testsuite/tests/typecheck/should_fail/T7645.hs @@ -1,8 +1,10 @@ {-# LANGUAGE TypeOperators, KindSignatures #-} module T7645 where +import Data.Kind + data (+) a b = P -f :: ((+) a (a :: *), Maybe) +f :: ((+) a (a :: Type), Maybe) f = undefined diff --git a/testsuite/tests/typecheck/should_fail/T7645.stderr b/testsuite/tests/typecheck/should_fail/T7645.stderr index 1b3fe0ad76..24330b2aeb 100644 --- a/testsuite/tests/typecheck/should_fail/T7645.stderr +++ b/testsuite/tests/typecheck/should_fail/T7645.stderr @@ -1,6 +1,5 @@ -T7645.hs:6:23: error: +T7645.hs:8:26: error: • Expecting one more argument to ‘Maybe’ Expected a type, but ‘Maybe’ has kind ‘* -> *’ - • In the type signature: - f :: ((+) a (a :: *), Maybe) + • In the type signature: f :: ((+) a (a :: Type), Maybe) diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 3a7f2c415b..6a0012700f 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -453,7 +453,6 @@ test('T13610', normal, compile_fail, ['']) test('T11672', normal, compile_fail, ['']) test('T13819', normal, compile_fail, ['']) test('T13902', normal, compile_fail, ['']) -test('T11963', normal, compile_fail, ['']) test('T14000', normal, compile_fail, ['']) test('T14055', normal, compile_fail, ['']) test('T13909', normal, compile_fail, ['']) diff --git a/testsuite/tests/typecheck/should_run/EtaExpandLevPoly.hs b/testsuite/tests/typecheck/should_run/EtaExpandLevPoly.hs index e912411209..d57d2e1499 100644 --- a/testsuite/tests/typecheck/should_run/EtaExpandLevPoly.hs +++ b/testsuite/tests/typecheck/should_run/EtaExpandLevPoly.hs @@ -1,5 +1,5 @@ -{-# LANGUAGE UnboxedTuples, MagicHash, GADTs, TypeInType, ExplicitForAll #-} - +{-# LANGUAGE UnboxedTuples, MagicHash, GADTs, + DataKinds, PolyKinds, ExplicitForAll #-} module Main where diff --git a/testsuite/tests/typecheck/should_run/KindInvariant.script b/testsuite/tests/typecheck/should_run/KindInvariant.script index a993d515c5..34f6be361e 100644 --- a/testsuite/tests/typecheck/should_run/KindInvariant.script +++ b/testsuite/tests/typecheck/should_run/KindInvariant.script @@ -1,12 +1,12 @@ -:set -XTypeInType -XDataKinds -XKindSignatures -XMagicHash -XPolyKinds +:set -XDataKinds -XKindSignatures -XMagicHash -XPolyKinds :m + Data.Kind GHC.Exts data T (a :: k -> k') :kind T State# -data T (a :: * -> k') +data T (a :: Type -> k') :kind T State# -- this should fail -data T (a :: * -> *) +data T (a :: Type -> Type) :kind T State# diff --git a/testsuite/tests/typecheck/should_run/T11120.hs b/testsuite/tests/typecheck/should_run/T11120.hs index f42e8cd5c0..5b5d7f343c 100644 --- a/testsuite/tests/typecheck/should_run/T11120.hs +++ b/testsuite/tests/typecheck/should_run/T11120.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, MagicHash, DataKinds #-} +{-# LANGUAGE MagicHash, DataKinds #-} -- See also TypeOf.hs import GHC.Prim diff --git a/testsuite/tests/typecheck/should_run/T12809.hs b/testsuite/tests/typecheck/should_run/T12809.hs index 9f6da26d76..66031a5af7 100644 --- a/testsuite/tests/typecheck/should_run/T12809.hs +++ b/testsuite/tests/typecheck/should_run/T12809.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType, ExplicitForAll, MagicHash, UnboxedTuples, +{-# LANGUAGE DataKinds, PolyKinds, ExplicitForAll, MagicHash, UnboxedTuples, TypeFamilies, GADTs #-} module Main where diff --git a/testsuite/tests/typecheck/should_run/T13435.hs b/testsuite/tests/typecheck/should_run/T13435.hs index 95ee946fa0..bc02f17b4c 100644 --- a/testsuite/tests/typecheck/should_run/T13435.hs +++ b/testsuite/tests/typecheck/should_run/T13435.hs @@ -1,4 +1,5 @@ -{-# Language FlexibleInstances, TypeFamilies, TypeInType, MagicHash #-} +{-# Language FlexibleInstances, TypeFamilies, + DataKinds, PolyKinds, MagicHash #-} module Main where diff --git a/testsuite/tests/typecheck/should_run/TypeOf.hs b/testsuite/tests/typecheck/should_run/TypeOf.hs index 59ea6fdf0d..11601a9a89 100644 --- a/testsuite/tests/typecheck/should_run/TypeOf.hs +++ b/testsuite/tests/typecheck/should_run/TypeOf.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DataKinds, UnicodeSyntax #-} import Data.Typeable import GHC.Types diff --git a/testsuite/tests/typecheck/should_run/TypeRep.hs b/testsuite/tests/typecheck/should_run/TypeRep.hs index 002e4fbac0..43d774a6b5 100644 --- a/testsuite/tests/typecheck/should_run/TypeRep.hs +++ b/testsuite/tests/typecheck/should_run/TypeRep.hs @@ -1,13 +1,15 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE ConstraintKinds #-} -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE PolyKinds #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE TypeOperators #-} +{-# LANGUAGE StarIsType #-} +{-# LANGUAGE UnicodeSyntax #-} import Data.Typeable import Data.Kind diff --git a/testsuite/tests/unboxedsums/sum_rr.hs b/testsuite/tests/unboxedsums/sum_rr.hs index 5f799fe481..448a9b2221 100644 --- a/testsuite/tests/unboxedsums/sum_rr.hs +++ b/testsuite/tests/unboxedsums/sum_rr.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeInType #-} +{-# LANGUAGE DataKinds, PolyKinds #-} module Example where |