summaryrefslogtreecommitdiff
path: root/compiler/types/Type.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-02-09 09:50:42 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-02-12 02:50:03 -0500
commit012257c15f584069500af2953ab70856f9a1470e (patch)
treee6822fee11572b3d04194da8c14b6e7f3794519d /compiler/types/Type.hs
parent6399965d7f1636db6c777f597192467f93d800b1 (diff)
downloadhaskell-012257c15f584069500af2953ab70856f9a1470e.tar.gz
Fix #16293 by cleaning up Proxy# infelicities
This bug fixes three problems related to `Proxy#`/`proxy#`: 1. Reifying it with TH claims that the `Proxy#` type constructor has two arguments, but that ought to be one for consistency with TH's treatment for other primitive type constructors like `(->)`. This was fixed by just returning the number of `tyConVisibleTyVars` instead of using `tyConArity` (which includes invisible arguments). 2. The role of `Proxy#`'s visible argument was hard-coded as nominal. Easily fixed by changing it to phantom. 3. The visibility of `proxy#`'s kind argument was specified, which is different from the `Proxy` constructor (which treats it as inferred). Some minor refactoring in `proxyHashId` fixed ths up. Along the way, I had to introduce a `mkSpecForAllTy` function, so I did some related Haddock cleanup in `Type`, where that function lives.
Diffstat (limited to 'compiler/types/Type.hs')
-rw-r--r--compiler/types/Type.hs24
1 files changed, 15 insertions, 9 deletions
diff --git a/compiler/types/Type.hs b/compiler/types/Type.hs
index e0ceb24b06..142da4c79c 100644
--- a/compiler/types/Type.hs
+++ b/compiler/types/Type.hs
@@ -36,7 +36,8 @@ module Type (
splitListTyConApp_maybe,
repSplitTyConApp_maybe,
- mkForAllTy, mkForAllTys, mkTyCoInvForAllTys, mkSpecForAllTys,
+ mkForAllTy, mkForAllTys, mkTyCoInvForAllTys,
+ mkSpecForAllTy, mkSpecForAllTys,
mkVisForAllTys, mkTyCoInvForAllTy,
mkInvForAllTy, mkInvForAllTys,
splitForAllTys, splitForAllVarBndrs,
@@ -1334,7 +1335,7 @@ interfaces. Notably this plays a role in tcTySigs in TcBinds.hs.
~~~~~~~~
-}
--- | Make a dependent forall over an Inferred variablem
+-- | Make a dependent forall over an 'Inferred' variable
mkTyCoInvForAllTy :: TyCoVar -> Type -> Type
mkTyCoInvForAllTy tv ty
| isCoVar tv
@@ -1343,13 +1344,13 @@ mkTyCoInvForAllTy tv ty
| otherwise
= ForAllTy (Bndr tv Inferred) ty
--- | Like mkTyCoInvForAllTy, but tv should be a tyvar
+-- | Like 'mkTyCoInvForAllTy', but tv should be a tyvar
mkInvForAllTy :: TyVar -> Type -> Type
mkInvForAllTy tv ty = ASSERT( isTyVar tv )
ForAllTy (Bndr tv Inferred) ty
--- | Like mkForAllTys, but assumes all variables are dependent and Inferred,
--- a common case
+-- | Like 'mkForAllTys', but assumes all variables are dependent and
+-- 'Inferred', a common case
mkTyCoInvForAllTys :: [TyCoVar] -> Type -> Type
mkTyCoInvForAllTys tvs ty = foldr mkTyCoInvForAllTy ty tvs
@@ -1357,12 +1358,17 @@ mkTyCoInvForAllTys tvs ty = foldr mkTyCoInvForAllTy ty tvs
mkInvForAllTys :: [TyVar] -> Type -> Type
mkInvForAllTys tvs ty = foldr mkInvForAllTy ty tvs
--- | Like mkForAllTys, but assumes all variables are dependent and Specified,
+-- | Like 'mkForAllTy', but assumes the variable is dependent and 'Specified',
-- a common case
+mkSpecForAllTy :: TyVar -> Type -> Type
+mkSpecForAllTy tv ty = ASSERT( isTyVar tv )
+ -- covar is always Inferred, so input should be tyvar
+ ForAllTy (Bndr tv Specified) ty
+
+-- | Like 'mkForAllTys', but assumes all variables are dependent and
+-- 'Specified', a common case
mkSpecForAllTys :: [TyVar] -> Type -> Type
-mkSpecForAllTys tvs = ASSERT( all isTyVar tvs )
- -- covar is always Inferred, so all inputs should be tyvar
- mkForAllTys [ Bndr tv Specified | tv <- tvs ]
+mkSpecForAllTys tvs ty = foldr mkSpecForAllTy ty tvs
-- | Like mkForAllTys, but assumes all variables are dependent and visible
mkVisForAllTys :: [TyVar] -> Type -> Type