summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-03-09 18:31:46 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-03-10 12:31:54 -0400
commit3300eeacbbf7a3d1f961f809be5d236c48827b28 (patch)
tree501af5e4ffa7cfb48057c620973fc3d076ea8212
parent7b2c827b7b68f0ade7f4ae66e7033fdb84d75a5f (diff)
downloadhaskell-3300eeacbbf7a3d1f961f809be5d236c48827b28.tar.gz
Misc cleanup
- Remove Note [Existentials in shift_con_pat]. The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4. - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon - Remove ASSERT in tyConAppArgN. It's already done by getNth, and it's the only reason getNth exists. - Remove unused function nextRole
-rw-r--r--compiler/GHC/HsToCore/Match/Constructor.hs32
-rw-r--r--compiler/typecheck/TcEnv.hs3
-rw-r--r--compiler/typecheck/TcHsType.hs14
-rw-r--r--compiler/typecheck/TcTyClsDecls.hs2
-rw-r--r--compiler/typecheck/TcType.hs2
-rw-r--r--compiler/types/Type.hs14
6 files changed, 9 insertions, 58 deletions
diff --git a/compiler/GHC/HsToCore/Match/Constructor.hs b/compiler/GHC/HsToCore/Match/Constructor.hs
index ab662a2f0e..3785fde948 100644
--- a/compiler/GHC/HsToCore/Match/Constructor.hs
+++ b/compiler/GHC/HsToCore/Match/Constructor.hs
@@ -261,36 +261,4 @@ positional patterns (T a b) and (a `T` b) all match the arguments
in order. Also T {} is special because it's equivalent to (T _ _).
Hence the (null rpats) checks here and there.
-
-Note [Existentials in shift_con_pat]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Consider
- data T = forall a. Ord a => T a (a->Int)
-
- f (T x f) True = ...expr1...
- f (T y g) False = ...expr2..
-
-When we put in the tyvars etc we get
-
- f (T a (d::Ord a) (x::a) (f::a->Int)) True = ...expr1...
- f (T b (e::Ord b) (y::a) (g::a->Int)) True = ...expr2...
-
-After desugaring etc we'll get a single case:
-
- f = \t::T b::Bool ->
- case t of
- T a (d::Ord a) (x::a) (f::a->Int)) ->
- case b of
- True -> ...expr1...
- False -> ...expr2...
-
-*** We have to substitute [a/b, d/e] in expr2! **
-Hence
- False -> ....((/\b\(e:Ord b).expr2) a d)....
-
-Originally I tried to use
- (\b -> let e = d in expr2) a
-to do this substitution. While this is "correct" in a way, it fails
-Lint, because e::Ord b but d::Ord a.
-
-}
diff --git a/compiler/typecheck/TcEnv.hs b/compiler/typecheck/TcEnv.hs
index c525ce15e9..71ca0044ad 100644
--- a/compiler/typecheck/TcEnv.hs
+++ b/compiler/typecheck/TcEnv.hs
@@ -456,6 +456,9 @@ tcLookupLocalIds ns
Just (ATcId { tct_id = id }) -> id
_ -> pprPanic "tcLookupLocalIds" (ppr name)
+-- inferInitialKind has made a suitably-shaped kind for the type or class
+-- Look it up in the local environment. This is used only for tycons
+-- that we're currently type-checking, so we're sure to find a TcTyCon.
tcLookupTcTyCon :: HasDebugCallStack => Name -> TcM TcTyCon
tcLookupTcTyCon name = do
thing <- tcLookup name
diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs
index 01e3bc19fc..b18b56fb56 100644
--- a/compiler/typecheck/TcHsType.hs
+++ b/compiler/typecheck/TcHsType.hs
@@ -32,7 +32,7 @@ module TcHsType (
ContextKind(..),
-- Type checking type and class decls
- kcLookupTcTyCon, bindTyClTyVars,
+ bindTyClTyVars,
etaExpandAlgTyCon, tcbVisibilities,
-- tyvars
@@ -2753,7 +2753,7 @@ bindTyClTyVars :: Name
-- in the "kind checking" and "type checking" pass,
-- but not in the initial-kind run.
bindTyClTyVars tycon_name thing_inside
- = do { tycon <- kcLookupTcTyCon tycon_name
+ = do { tycon <- tcLookupTcTyCon tycon_name
; let scoped_prs = tcTyConScopedTyVars tycon
res_kind = tyConResKind tycon
binders = tyConBinders tycon
@@ -2761,16 +2761,6 @@ bindTyClTyVars tycon_name thing_inside
; tcExtendNameTyVarEnv scoped_prs $
thing_inside binders res_kind }
--- inferInitialKind has made a suitably-shaped kind for the type or class
--- Look it up in the local environment. This is used only for tycons
--- that we're currently type-checking, so we're sure to find a TcTyCon.
-kcLookupTcTyCon :: Name -> TcM TcTyCon
-kcLookupTcTyCon nm
- = do { tc_ty_thing <- tcLookup nm
- ; return $ case tc_ty_thing of
- ATcTyCon tc -> tc
- _ -> pprPanic "kcLookupTcTyCon" (ppr tc_ty_thing) }
-
{- *********************************************************************
* *
diff --git a/compiler/typecheck/TcTyClsDecls.hs b/compiler/typecheck/TcTyClsDecls.hs
index e712f79e1d..2c4c09722c 100644
--- a/compiler/typecheck/TcTyClsDecls.hs
+++ b/compiler/typecheck/TcTyClsDecls.hs
@@ -1503,7 +1503,7 @@ kcLTyClDecl :: LTyClDecl GhcRn -> TcM ()
-- Called only for declarations without a signature (no CUSKs or SAKs here)
kcLTyClDecl (L loc decl)
= setSrcSpan loc $
- do { tycon <- kcLookupTcTyCon tc_name
+ do { tycon <- tcLookupTcTyCon tc_name
; traceTc "kcTyClDecl {" (ppr tc_name)
; addVDQNote tycon $ -- See Note [Inferring visible dependent quantification]
addErrCtxt (tcMkDeclCtxt decl) $
diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs
index 65e77ab9da..205951ddc8 100644
--- a/compiler/typecheck/TcType.hs
+++ b/compiler/typecheck/TcType.hs
@@ -68,7 +68,7 @@ module TcType (
tcTyConAppTyCon, tcTyConAppTyCon_maybe, tcTyConAppArgs,
tcSplitAppTy_maybe, tcSplitAppTy, tcSplitAppTys, tcRepSplitAppTy_maybe,
tcRepGetNumAppTys,
- tcGetCastedTyVar_maybe, tcGetTyVar_maybe, tcGetTyVar, nextRole,
+ tcGetCastedTyVar_maybe, tcGetTyVar_maybe, tcGetTyVar,
tcSplitSigmaTy, tcSplitNestedSigmaTys, tcDeepSplitSigmaTy_maybe,
---------------------------------
diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs
index 71a0622787..2f87ca7a2f 100644
--- a/compiler/types/Type.hs
+++ b/compiler/types/Type.hs
@@ -34,7 +34,7 @@ module Type (
mkTyConApp, mkTyConTy,
tyConAppTyCon_maybe, tyConAppTyConPicky_maybe,
tyConAppArgs_maybe, tyConAppTyCon, tyConAppArgs,
- splitTyConApp_maybe, splitTyConApp, tyConAppArgN, nextRole,
+ splitTyConApp_maybe, splitTyConApp, tyConAppArgN,
tcSplitTyConApp_maybe,
splitListTyConApp_maybe,
repSplitTyConApp_maybe,
@@ -1267,7 +1267,7 @@ tyConAppArgN :: Int -> Type -> Type
-- Executing Nth
tyConAppArgN n ty
= case tyConAppArgs_maybe ty of
- Just tys -> ASSERT2( tys `lengthExceeds` n, ppr n <+> ppr tys ) tys `getNth` n
+ Just tys -> tys `getNth` n
Nothing -> pprPanic "tyConAppArgN" (ppr n <+> ppr ty)
-- | Attempts to tease a type apart into a type constructor and the application
@@ -1322,16 +1322,6 @@ splitListTyConApp_maybe ty = case splitTyConApp_maybe ty of
Just (tc,[e]) | tc == listTyCon -> Just e
_other -> Nothing
-nextRole :: Type -> Role
-nextRole ty
- | Just (tc, tys) <- splitTyConApp_maybe ty
- , let num_tys = length tys
- , num_tys < tyConArity tc
- = tyConRoles tc `getNth` num_tys
-
- | otherwise
- = Nominal
-
newTyConInstRhs :: TyCon -> [Type] -> Type
-- ^ Unwrap one 'layer' of newtype on a type constructor and its
-- arguments, using an eta-reduced version of the @newtype@ if possible.