• simonpj's avatar
    [project @ 2001-03-05 12:45:45 by simonpj] · e6dff21d
    simonpj authored
    Improve SpecConstr
    
    This commit fixes SpecConstr so that it can see the effect of
    enclosing case expressions properly.  That's what the "cons" field
    in ScEnv is for.
    
    As a result, consider this function:
    
      data AccessPath = Cont  AccessPath
    		  | Value Int
    
      demandAll n ap@(Cont (Value (I# i1)))
        = case n of
    	0     -> i1
    	other -> i1 +# demandAll (n-1) ap
    
    SpecConstr now successfully compiles it to this:
    
      $s$wdemandAll
        = \ i1 :: PrelGHC.Int# sc :: PrelGHC.Int# ->
          case sc of ds {
    	0 -> i1;
    	__DEFAULT -> PrelGHC.+# i1 (Foo.$s$wdemandAll i1 (PrelGHC.-# ds 1))
          }
    
    with the rule
    
     "SC:$wdemandAll1" __forall i1 :: PrelGHC.Int# ,
    			    sc :: PrelGHC.Int# .
    	Foo.$wdemandAll sc (Foo.$wCont (Foo.$wValue (PrelBase.$wI# i1)))
    	= Foo.$s$wdemandAll i1 sc ;
    e6dff21d