Name shadowing in types in Core

Simon Peyton-Jones simonpj at microsoft.com
Wed Apr 9 03:37:14 EDT 2008


Yes, in principle Core certainly allows shadowing. It's very hard to guaranteed that it's avoided, unless you do a sweep that does nothing but eliminate it.  That said, the Simplifier does remove as much shadowing as it can, as it goes.

I've no objection to allowing shadowing in External Core.

Simon

| -----Original Message-----
| From: cvs-ghc-bounces at haskell.org [mailto:cvs-ghc-bounces at haskell.org] On
| Behalf Of Tim Chevalier
| Sent: 09 April 2008 00:44
| To: Cvs-ghc at haskell.org
| Subject: Name shadowing in types in Core
|
| Hi all,
|
| When compiling the Data.Generics.Basics library module to External
| Core, the resulting .hcr file includes the following data declaration:
|
| %data base:DataziGenericsziBasics.ZCTData a =
|   {base:DataziGenericsziBasics.ZCDData (^base:DataziTypeable.ZCTTypeable
|                                          a)
|                                         (%forall (c::(*->*)) .
| (%forall a b . base:DataziGenericsziBasics.ZCTData
|
| a
|
| ->
|
|        c (a -> b) ->
|
|        a -> c b)
|                                                                ->
|
| (%forall g . g -> c g) -> a -> c a)
| [remainder of type snipped to prevent brain damage]
| }
|
| The point to notice is that the outer declaration of the tyvar "a" (as
| an argument to ZCTData) is shadowed by the inner forall binding of a.
|
| The External Core document says External Core doesn't allow name
| shadowing in either terms or types. So I thought about modifying the
| External Core printer within GHC to uniquely rename types, but that
| would be tedious; instead, I'm inclined to just change the
| documentation to say that name shadowing is allowed in types but not
| in terms. Before I do that, though, I thought I would ask: Is type
| variable name shadowing supposed to be allowed in internal Core? Or
| does this reflect a bug in GHC?
|
| Cheers,
| Tim
|
| --
| Tim Chevalier * http://cs.pdx.edu/~tjc * Often in error, never in doubt
| "and there's too much darkness in an endless night to be afraid of the
| way we feel" -- Bob Franke
|
| _______________________________________________
| Cvs-ghc mailing list
| Cvs-ghc at haskell.org
| http://www.haskell.org/mailman/listinfo/cvs-ghc



More information about the Cvs-ghc mailing list