Skip to content
  • Simon Peyton Jones's avatar
    [project @ 2001-09-07 12:44:30 by simonpj] · 991a868b
    Simon Peyton Jones authored
    ----------------------------------------
    	Make dict funs and default methods
    	into LocalIds only at their binding site
    	----------------------------------------
            [part of 3 related commits]
    
    There's a long comment about this with MkId.mkDefaultMethodId,
    which I reproduce below.
    
    While I was at it, I renamed setIdNoDiscard to setIdLocalExported.
    Which is hardly an improvement, I'm afraid.  This renaming touches
    	Var.lhs, Id.lhs, SimplCore.lhs
    in a trivial way.
    
    	---------------------
    
    Dict funs and default methods are *not* ImplicitIds.  Their definition
    involves user-written code, so we can't figure out their strictness etc
    based on fixed info, as we can for constructors and record selectors (say).
    
    We build them as GlobalIds, but when in the module where they are
    bound, we turn the Id at the *binding site* into an exported LocalId.
    This ensures that they are taken to account by free-variable finding
    and dependency analysis (e.g. CoreFVs.exprFreeVars).   The simplifier
    will propagate the LocalId to all occurrence sites.
    
    Why shouldn't they be bound as GlobalIds?  Because, in particular, if
    they are globals, the specialiser floats dict uses above their defns,
    which prevents good simplifications happening.  Also the strictness
    analyser treats a occurrence of a GlobalId as imported and assumes it
    contains strictness in its IdInfo, which isn't true if the thing is
    bound in the same module as the occurrence.
    
    It's OK for dfuns to be LocalIds, because we form the instance-env to
    pass on to the next module (md_insts) in CoreTidy, afer tidying
    and globalising the top-level Ids.
    
    BUT make sure they are *exported* LocalIds (setIdLocalExported) so
    that they aren't discarded by the occurrence analyser.
    991a868b