[commit: ghc] master: Make exprType work correctly in the presnce of type bindings (Trac #8522) (96e6edd)
git at git.haskell.org
git at git.haskell.org
Tue Nov 12 15:10:27 UTC 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/96e6eddc40c34a171f6261a7814a1e264457ce86/ghc
>---------------------------------------------------------------
commit 96e6eddc40c34a171f6261a7814a1e264457ce86
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Tue Nov 12 15:10:01 2013 +0000
Make exprType work correctly in the presnce of type bindings (Trac #8522)
>---------------------------------------------------------------
96e6eddc40c34a171f6261a7814a1e264457ce86
compiler/coreSyn/CoreUtils.lhs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs
index f717049..264a9da 100644
--- a/compiler/coreSyn/CoreUtils.lhs
+++ b/compiler/coreSyn/CoreUtils.lhs
@@ -86,7 +86,10 @@ exprType :: CoreExpr -> Type
exprType (Var var) = idType var
exprType (Lit lit) = literalType lit
exprType (Coercion co) = coercionType co
-exprType (Let _ body) = exprType body
+exprType (Let bind body)
+ | NonRec tv rhs <- bind -- See Note [Type bindings]
+ , Type ty <- rhs = substTyWith [tv] [ty] (exprType body)
+ | otherwise = exprType body
exprType (Case _ _ ty _) = ty
exprType (Cast _ co) = pSnd (coercionKind co)
exprType (Tick _ e) = exprType e
@@ -113,6 +116,15 @@ coreAltsType (alt:_) = coreAltType alt
coreAltsType [] = panic "corAltsType"
\end{code}
+Note [Type bindings]
+~~~~~~~~~~~~~~~~~~~~
+Core does allow type bindings, although such bindings are
+not much used, except in the output of the desuguarer.
+Example:
+ let a = Int in (\x:a. x)
+Given this, exprType must be careful to substitute 'a' in the
+result type (Trac #8522).
+
Note [Existential variables and silly type synonyms]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
More information about the ghc-commits
mailing list