
#8995: When generalising, use levels rather than global tyvars -------------------------------------+------------------------------------ Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): Thanks Didier. First, two confusions: * I think of let-bindings of form `let x = <rhs> in <body>`. So when I say "RHS" I mean the bit that you called `a2` above. So I think we are in agreement here. * In principle GHC does not do local let-generalisation, as our papers advertise. But GHC must compile Haskell 98, so it must somehow support local let-generalisation. So in fact: * Local let-gen is enabled by `-XNoMonoLocalBinds` and disabled by `-XMonoLocalBinds`. * By default, we have `-XNoMonoLocalBinds`. * But with `-XGADTs` or `-XTypeFamilies` we also switch on `-XMonoLocalBinds`. * But that can again be overridden, so `-XGADTs -XNoMonoLocalBings` would attempt to generalise local let-bindings despite the problems with doing so. The other thing is that the "monomorphism restriction" can mean that even a top-level binding can have an environment with free type variables. `-XNoMonomorphismRestriction` switches this off. So this ticket is all about the "best-efforts" generalisation you get when you have `-XNoMonoLocalBinds`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8995#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler