summaryrefslogtreecommitdiff
path: root/compiler/deSugar
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2008-06-05 12:36:12 +0000
committersimonpj@microsoft.com <unknown>2008-06-05 12:36:12 +0000
commit1b1190e01d0c65043628d2532988d9b1b4a78384 (patch)
treec3a0d78d2661525477910312fdbbc47f63706683 /compiler/deSugar
parent628ca41da974b157a374280b7abfe550e12b22b0 (diff)
downloadhaskell-1b1190e01d0c65043628d2532988d9b1b4a78384.tar.gz
Add non-recursive let-bindings for types
This patch adds to Core the ability to say let a = Int in <body> where 'a' is a type variable. That is: a type-let. See Note [Type let] in CoreSyn. * The binding is always non-recursive * The simplifier immediately eliminates it by substitution So in effect a type-let is just a delayed substitution. This is convenient in a couple of places in the desugarer, one existing (see the call to CoreTyn.mkTyBind in DsUtils), and one that's in the next upcoming patch. The first use in the desugarer was previously encoded as (/\a. <body>) Int rather that eagerly substituting, but that was horrid because Core Lint had do "know" that a=Int inside <body> else it would bleat. Expressing it directly as a 'let' seems much nicer.
Diffstat (limited to 'compiler/deSugar')
-rw-r--r--compiler/deSugar/DsUtils.lhs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/deSugar/DsUtils.lhs b/compiler/deSugar/DsUtils.lhs
index 4334a12803..553b468832 100644
--- a/compiler/deSugar/DsUtils.lhs
+++ b/compiler/deSugar/DsUtils.lhs
@@ -347,10 +347,10 @@ wrapBinds [] e = e
wrapBinds ((new,old):prs) e = wrapBind new old (wrapBinds prs e)
wrapBind :: Var -> Var -> CoreExpr -> CoreExpr
-wrapBind new old body
+wrapBind new old body -- Can deal with term variables *or* type variables
| new==old = body
- | isTyVar new = App (Lam new body) (Type (mkTyVarTy old))
- | otherwise = Let (NonRec new (Var old)) body
+ | isTyVar new = Let (mkTyBind new (mkTyVarTy old)) body
+ | otherwise = Let (NonRec new (Var old)) body
seqVar :: Var -> CoreExpr -> CoreExpr
seqVar var body = Case (Var var) var (exprType body)