Add non-recursive let-bindings for types
authorsimonpj@microsoft.com <unknown>
Thu, 5 Jun 2008 12:36:12 +0000 (12:36 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 5 Jun 2008 12:36:12 +0000 (12:36 +0000)
commit1b1190e01d0c65043628d2532988d9b1b4a78384
treec3a0d78d2661525477910312fdbbc47f63706683
parent628ca41da974b157a374280b7abfe550e12b22b0
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.
compiler/coreSyn/CoreLint.lhs
compiler/coreSyn/CoreSyn.lhs
compiler/coreSyn/PprCore.lhs
compiler/deSugar/DsUtils.lhs
compiler/simplCore/OccurAnal.lhs
compiler/simplCore/Simplify.lhs