[get rid of 'inb' argument to simplifier, in favor of the one that is handed around in the monad
John Meacham <john@repetae.net>**20061129033503] hunk ./E/SSimplify.hs 11
-import Control.Monad.RWS
+import Util.RWS
hunk ./E/SSimplify.hs 369
-substLookup :: Id -> Env -> Maybe Range
-substLookup id env = mlookup id (envSubst env)
+substLookup :: Id -> SM (Maybe Range)
+substLookup id = SM $ ask >>= return . mlookup id . envSubst
hunk ./E/SSimplify.hs 374
---applySubst :: Subst -> IdMap a -> E -> E
---applySubst s nn = applySubst' s where
---    nn' = fmap (const Nothing) s `mappend` fmap (const Nothing) nn
---    applySubst' s = substMap'' (tm `mappend` nn') where
---        tm = fmap g s
---        g (Done e) = Just e
---        g (Susp e s') = Just $ applySubst' s' e
-
-{-
-applySubst :: Subst -> IdMap a -> E -> E
-applySubst s nn = applySubst' s where
-    nn' = fmap (const Nothing) s `mappend` fmap (const Nothing) nn
-    applySubst' s = substMap'' (tm `mappend` nn') where
-        tm = fmap g s
-        g (Done e) = Just e
-        g (Susp _ _ e)  = Just e
-        --g (Susp e s')  = Just $ applySubst' s' e
--}
hunk ./E/SSimplify.hs 383
---mkSubst :: Range -> Maybe E
---mkSubst (Done e) = Just e
---mkSubst (Susp _ _ e) = Just e
---mkSubst (Susp e s' e) = Just $ substMap'' (fmap mkSubst s') e
hunk ./E/SSimplify.hs 384
---cacheSubst env = env { envCachedSubst = fmap mkSubst (envSubst env) }
hunk ./E/SSimplify.hs 386
-dosub inb e = coerceOpt return $ substMap'' (envCachedSubst inb) e
-
---dosub inb e = coerceOpt return $ applySubst (envSubst inb) (envInScope inb) e
+dosub e = ask >>= \inb ->  coerceOpt return (substMap'' (envCachedSubst inb) e)
hunk ./E/SSimplify.hs 428
-        doDs dsIn initialB
-    go :: E -> Env -> SM E
-    go e inb = do
+        doDs dsIn
+    go :: E -> SM E
+    go e = do
hunk ./E/SSimplify.hs 432
-        f e' (cacheSubst inb { envSubst = mempty })
-    f :: InE -> Env -> SM OutE
-    f e inb | (ELam t b,(x:xs)) <- fromAp e = do
+        localEnv (envSubst_s mempty) $ f e'
+    f :: InE -> SM OutE
+    f e | (ELam t b,(x:xs)) <- fromAp e = do
hunk ./E/SSimplify.hs 436
-        xs' <- mapM (dosub inb) xs
-        b' <- f b (insertSuspSubst t x inb) -- minsert (tvrIdent t) (Susp x sub) sub) inb
+        xs' <- mapM dosub xs
+        b' <- localEnv (insertSuspSubst t x) $ f b
hunk ./E/SSimplify.hs 439
-        h b' xs' inb
-    f e inb | (EPi t b,(x:xs)) <- fromAp e = do
+        h b' xs'
+    f e| (EPi t b,(x:xs)) <- fromAp e = do
hunk ./E/SSimplify.hs 442
-        xs' <- mapM (dosub inb) xs
-        b' <- f b (insertSuspSubst t x inb) -- (minsert (tvrIdent t) (Susp x sub) sub) inb
+        xs' <- mapM dosub xs
+        b' <- localEnv (insertSuspSubst t x) $ f b
hunk ./E/SSimplify.hs 445
-        h b' xs' inb
-    f e inb | (EVar v,xs) <- fromAp e = do
-        xs' <- mapM (dosub inb) xs
-        case substLookup (tvrIdent v) inb of
-            Just (Done e) -> h e xs' inb   -- e is var or trivial
+        h b' xs'
+    f e | (EVar v,xs) <- fromAp e = do
+        xs' <- mapM dosub xs
+        z <- substLookup (tvrIdent v)
+        case z of
+            Just (Done e) -> h e xs'   -- e is var or trivial
hunk ./E/SSimplify.hs 452
-                e' <- f e (cacheSubst inb { envSubst = s })
-                h e' xs' inb
-            Nothing -> h (EVar v) xs' inb
-    f e inb | (x,xs) <- fromAp e = do
+                e' <- localEnv (envSubst_s s)  $ f e
+                h e' xs'
+            Nothing -> h (EVar v) xs'
+    f e | (x,xs) <- fromAp e = do
hunk ./E/SSimplify.hs 458
-            Just (_,e) -> f e inb -- go e inb
+            Just (_,e) -> f e
hunk ./E/SSimplify.hs 460
-                xs' <- mapM (dosub inb) xs
-                x' <- g x inb
+                xs' <- mapM dosub xs
+                x' <- g x
hunk ./E/SSimplify.hs 464
-                h x xs' inb
-    g (EPrim a es t) inb = do
-        es' <- mapM (dosub inb) es
-        t' <- dosub inb t
-        return $ EPrim a es' t'
-    g (ELit lc@LitCons { litName = n, litArgs = es, litType = t }) inb = do
-        es' <- mapM (dosub inb) es
-        t' <- dosub inb t
+                h x xs'
+    g (EPrim a es t) = return (EPrim a) `ap` mapM dosub es `ap` dosub t
+    g (ELit lc@LitCons { litName = n, litArgs = es, litType = t }) = do
+        es' <- mapM dosub es
+        t' <- dosub t
hunk ./E/SSimplify.hs 470
-    g (ELit (LitInt n t)) inb = do
-        t' <- dosub inb t
+    g (ELit (LitInt n t)) = do
+        t' <- dosub t
hunk ./E/SSimplify.hs 473
-    g e@(EPi (TVr { tvrIdent = n }) b) inb = do
+    g e@(EPi (TVr { tvrIdent = n }) b) = do
hunk ./E/SSimplify.hs 475
-        e' <- dosub inb e
+        e' <- dosub e
hunk ./E/SSimplify.hs 477
-    g (EError s t) inb = do
-        t' <- dosub inb t
-        return $ EError s t'
-    g ec@ECase { eCaseScrutinee = e, eCaseBind = b, eCaseAlts = as, eCaseDefault = d} inb = do
+    g (EError s t) = do EError s `fmap` dosub t
+    g ec@ECase { eCaseScrutinee = e, eCaseBind = b, eCaseAlts = as, eCaseDefault = d} = do
hunk ./E/SSimplify.hs 480
-        e' <- f e inb
-        doCase e' (eCaseType ec) b as d inb
-    g (ELam v e) inb  = do
+        e' <- f e
+        doCase e' (eCaseType ec) b as d
+    g (ELam v e)  = do
hunk ./E/SSimplify.hs 484
-        v' <- nname v inb
-        e' <- f e (insertDoneSubst v (EVar v') . insertInScope (tvrIdent v') NotKnown $ inb) --        minsert (tvrIdent v) (Done $ EVar v') sub)
+        v' <- nname v
+        e' <- localEnv (insertDoneSubst v (EVar v') . insertInScope (tvrIdent v') NotKnown) $ f e
hunk ./E/SSimplify.hs 487
-    g ELetRec { eDefs = ds@(_:_), eBody =  e } inb = do
-        (ds',inb') <- doDs ds inb
-        e' <- f e inb'
+    g ELetRec { eDefs = ds@(_:_), eBody =  e } = do
+        (ds',inb') <- doDs ds
+        e' <- localEnv (const inb') $ f e
hunk ./E/SSimplify.hs 511
-    g e _ = error $ "SSimplify.simplify.g: " ++ show e ++ "\n" ++ pprint e
+    g e = error $ "SSimplify.simplify.g: " ++ show e ++ "\n" ++ pprint e
hunk ./E/SSimplify.hs 515
-    nname tvr@(TVr { tvrIdent = n, tvrType =  t}) inb  = do
-        t' <- dosub inb t
+    nname tvr@(TVr { tvrIdent = n, tvrType =  t})  = do
+        t' <- dosub t
+        inb <- ask
hunk ./E/SSimplify.hs 522
-    doCase :: OutE -> InE -> InTVr -> [Alt InE] -> (Maybe InE) -> Env -> SM OutE
-    doCase ELetRec { eDefs = ds, eBody = e} t b as d inb = do
+    doCase :: OutE -> InE -> InTVr -> [Alt InE] -> (Maybe InE) ->  SM OutE
+    doCase ELetRec { eDefs = ds, eBody = e} t b as d = do
hunk ./E/SSimplify.hs 525
-        e' <- doCase e t b as d inb
+        e' <- doCase e t b as d
hunk ./E/SSimplify.hs 528
-    doCase (EVar v) t b as d inb |  Just IsBoundTo { bindingE = ELit l } <- mlookup (tvrIdent v) (envInScope inb)  = doConstCase l t  b as d inb
-    doCase (ELit l) t b as d inb  = doConstCase l t b as d inb
+    --doCase (EVar v) t b as d inb |  Just IsBoundTo { bindingE = ELit l } <- mlookup (tvrIdent v) (envInScope inb)  = doConstCase l t  b as d inb
+    doCase (ELit l) t b as d  = doConstCase l t b as d
hunk ./E/SSimplify.hs 531
-    doCase (EVar v) t b as d inb | Just IsBoundTo { bindingE = e } <- mlookup (tvrIdent v) (envInScope inb) , isBottom e = do
-        mtick "E.Simplify.case-of-bottom'"
-        t' <- dosub inb t
-        return $ prim_unsafeCoerce (EVar v) t'
-    doCase e t b as d inb | isBottom e = do
+    --doCase (EVar v) t b as d inb | Just IsBoundTo { bindingE = e } <- mlookup (tvrIdent v) (envInScope inb) , isBottom e = do
+    --    mtick "E.Simplify.case-of-bottom'"
+    --    t' <- dosub inb t
+    --    return $ prim_unsafeCoerce (EVar v) t'
+    doCase e t b as d | isBottom e = do
hunk ./E/SSimplify.hs 537
-        t' <- dosub inb t
+        t' <- dosub t
hunk ./E/SSimplify.hs 540
-    doCase ic@ECase { eCaseScrutinee = e, eCaseBind =  b, eCaseAlts =  as, eCaseDefault =  d } t b' as' d' inb | length (filter (not . isBottom) (caseBodies ic)) <= 1 || all whnfOrBot (caseBodies ic)  || all whnfOrBot (caseBodies emptyCase { eCaseAlts = as', eCaseDefault = d'} )  = do
+    doCase ic@ECase { eCaseScrutinee = e, eCaseBind =  b, eCaseAlts =  as, eCaseDefault =  d } t b' as' d' | length (filter (not . isBottom) (caseBodies ic)) <= 1 || all whnfOrBot (caseBodies ic)  || all whnfOrBot (caseBodies emptyCase { eCaseAlts = as', eCaseDefault = d'} )  = do
hunk ./E/SSimplify.hs 543
-                e' <- doCase e t b' as' d' (cacheSubst $ envInScope_u (fromList [ (n,NotKnown) | TVr { tvrIdent = n } <- litBinds l ] `union`) inb)
+                e' <- localEnv (envInScope_u (fromList [ (n,NotKnown) | TVr { tvrIdent = n } <- litBinds l ] `union`)) $ doCase e t b' as' d'
hunk ./E/SSimplify.hs 546
-            g x = doCase x t b' as' d' (insertInScope (tvrIdent b) NotKnown inb)
+            g x = localEnv (insertInScope (tvrIdent b) NotKnown) $ doCase x t b' as' d'
hunk ./E/SSimplify.hs 549
-        t' <- dosub inb t
+        t' <- dosub t
hunk ./E/SSimplify.hs 551
-    doCase e t b as@(Alt LitCons { litName = n } _:_) (Just d) inb | Just ss <- getSiblings (so_dataTable sopts) n, length ss <= length as = do
+    doCase e t b as@(Alt LitCons { litName = n } _:_) (Just d) | Just ss <- getSiblings (so_dataTable sopts) n, length ss <= length as = do
hunk ./E/SSimplify.hs 553
-        doCase e t b as Nothing inb
-    doCase e t b as (Just d) inb | te /= tWorld__, (ELit LitCons { litName = cn }) <- followAliases dt te, Just Constructor { conChildren = Just cs } <- getConstructor cn dt, length as == length cs - 1 || (False && length as < length cs && isAtomic d)  = do
+        doCase e t b as Nothing
+    doCase e t b as (Just d) | te /= tWorld__, (ELit LitCons { litName = cn }) <- followAliases dt te, Just Constructor { conChildren = Just cs } <- getConstructor cn dt, length as == length cs - 1 || (False && length as < length cs && isAtomic d)  = do
hunk ./E/SSimplify.hs 567
-        ec <- dosub inb $ caseUpdate emptyCase { eCaseScrutinee = e, eCaseType = t, eCaseBind = b, eCaseAlts = as ++ ls' }
+        ec <- dosub $ caseUpdate emptyCase { eCaseScrutinee = e, eCaseType = t, eCaseBind = b, eCaseAlts = as ++ ls' }
hunk ./E/SSimplify.hs 573
-    doCase e _ b [] (Just d) inb | not (isLifted e || isUnboxed (getType e)) = do
+    doCase e _ b [] (Just d) | not (isLifted e || isUnboxed (getType e)) = do
hunk ./E/SSimplify.hs 575
-        b' <- nname b inb
-        d' <- f d (insertDoneSubst b (EVar b') (insertInScope (tvrIdent b') (fixInline finalPhase b' $ isBoundTo noUseInfo e) inb))
+        b' <- nname b
+        d' <- localEnv (insertDoneSubst b (EVar b') . (insertInScope (tvrIdent b') (fixInline finalPhase b' $ isBoundTo noUseInfo e))) $ f d
hunk ./E/SSimplify.hs 578
-    doCase e@ELam {} _ b [] (Just d) inb  = do
+    doCase e@ELam {} _ b [] (Just d)  = do
hunk ./E/SSimplify.hs 580
-        b' <- nname b inb
-        d' <- f d (insertDoneSubst b (EVar b') (insertInScope (tvrIdent b') (fixInline finalPhase b' $ isBoundTo noUseInfo e) inb))
+        b' <- nname b
+        d' <- localEnv (insertDoneSubst b (EVar b') . (insertInScope (tvrIdent b') (fixInline finalPhase b' $ isBoundTo noUseInfo e))) $ f d
hunk ./E/SSimplify.hs 584
-    doCase e _ b [] (Just d) inb | isUnboxed (getType e), isAtomic e = do
+    doCase e _ b [] (Just d) | isUnboxed (getType e), isAtomic e = do
hunk ./E/SSimplify.hs 586
-        f d (insertDoneSubst b e inb) -- minsert (tvrIdent b) (Done e) sub) inb
-        --f d (minsert (tvrIdent b) (Susp e sub) sub) inb
-    doCase e _ TVr { tvrIdent = 0 } [] (Just d) inb | isOmittable inb e = do
-        mtick "E.Simplify.case-omittable"
-        f d inb
-    doCase (EVar v) _ b [] (Just d) inb | Just (NotAmong _) <-  mlookup (tvrIdent v) (envInScope inb)  = do
-        mtick "E.Simplify.case-evaled"
-        d' <- f d (insertDoneSubst b (EVar v) inb) -- minsert (tvrIdent b) (Done (EVar v)) sub) inb
-        return d'
-    doCase e _ b [] (Just (EVar v')) inb | b == v' = do
+        localEnv (insertDoneSubst b e) $ f d
+    --doCase e _ TVr { tvrIdent = 0 } [] (Just d) inb | isOmittable inb e = do
+    --    mtick "E.Simplify.case-omittable"
+    --    f d inb
+    --doCase (EVar v) _ b [] (Just d) inb | Just (NotAmong _) <-  mlookup (tvrIdent v) (envInScope inb)  = do
+    --    mtick "E.Simplify.case-evaled"
+    --    d' <- f d (insertDoneSubst b (EVar v) inb) -- minsert (tvrIdent b) (Done (EVar v)) sub) inb
+    --    return d'
+    -- TODO valid only in strict context
+    doCase e _ b [] (Just (EVar v')) | b == v' = do
hunk ./E/SSimplify.hs 598
-    doCase scrut _ v [] (Just sc@ECase { eCaseScrutinee = EVar v'} ) inb | v == v', tvrIdent v `notMember` (freeVars (caseBodies sc) :: IdSet)  = do
+    doCase scrut _ v [] (Just sc@ECase { eCaseScrutinee = EVar v'} ) | v == v', tvrIdent v `notMember` (freeVars (caseBodies sc) :: IdSet)  = do
hunk ./E/SSimplify.hs 600
-        doCase scrut (eCaseType sc) (eCaseBind sc) (eCaseAlts sc) (eCaseDefault sc) inb
-    --    f sc { eCaseScrutinee = scrut } sub inb
-    doCase e t b as d inb = do
-        b' <- nname b inb
+        doCase scrut (eCaseType sc) (eCaseBind sc) (eCaseAlts sc) (eCaseDefault sc)
+    doCase e t b as d = do
+        b' <- nname b
hunk ./E/SSimplify.hs 610
-        let dd e' = f e' ( ids $ envInScope_u (newinb `union`) inb) where
+        inb <- ask
+        let dd e' = localEnv (const $ ids $ envInScope_u (newinb `union`) inb) $ f e' where
hunk ./E/SSimplify.hs 615
-                t' <- dosub inb t
+                t' <- dosub t
hunk ./E/SSimplify.hs 617
-                e' <- f ae (ids $ mins e (patToLitEE p') inb)
+                e' <- localEnv (ids . mins e (patToLitEE p')) $ f ae
hunk ./E/SSimplify.hs 620
-                t' <- dosub inb t
-                ns' <- mapM (\v -> nname v inb) ns
+                t' <- dosub t
+                ns' <- mapM nname ns
hunk ./E/SSimplify.hs 625
-                e' <- f ae (ids $ substAddList nsub (envInScope_u (ninb `union`) $ mins e (patToLitEE p') inb))
+                e' <- localEnv (const $ ids $ substAddList nsub (envInScope_u (ninb `union`) $ mins e (patToLitEE p') inb)) $ f ae
hunk ./E/SSimplify.hs 634
-        t' <- dosub inb t
+        t' <- dosub t
hunk ./E/SSimplify.hs 647
-    doConstCase :: {- Out -} Lit E E -> InE -> InTVr -> [Alt E] -> Maybe InE -> Env -> SM OutE
-    doConstCase l t b as d inb = do
-        t' <- dosub inb t
+    doConstCase :: {- Out -} Lit E E -> InE -> InTVr -> [Alt E] -> Maybe InE -> SM OutE
+    doConstCase l t b as d = do
+        t' <- dosub t
hunk ./E/SSimplify.hs 651
+        inb <- ask
hunk ./E/SSimplify.hs 655
-                binds <- mapM (\ (v,e) -> nname v inb >>= return . (,,) e v) bs'
-                e' <- f e (substAddList [ (n,Done $ EVar nt) | (_,TVr { tvrIdent = n },nt) <- binds] $ envInScope_u (fromList [ (n,isBoundTo noUseInfo e) | (e,_,TVr { tvrIdent = n }) <- binds] `union`) inb)
+                binds <- mapM (\ (v,e) -> nname v >>= return . (,,) e v) bs'
+                e' <- localEnv (const $ substAddList [ (n,Done $ EVar nt) | (_,TVr { tvrIdent = n },nt) <- binds] $ envInScope_u (fromList [ (n,isBoundTo noUseInfo e) | (e,_,TVr { tvrIdent = n }) <- binds] `union`) inb) $ f e
hunk ./E/SSimplify.hs 679
-    applyRule :: OutTVr -> [OutE] -> Env -> SM (Maybe (OutE,[OutE]))
-    applyRule v xs inb  = do
+    applyRule :: OutTVr -> [OutE] -> SM (Maybe (OutE,[OutE]))
+    applyRule v xs  = do
+        inb <- ask
hunk ./E/SSimplify.hs 689
-    h :: OutE -> [OutE] -> Env -> SM OutE
-    h (EVar v) xs' inb = do
-        z <- applyRule v xs' inb
+    h :: OutE -> [OutE] -> SM OutE
+    h (EVar v) xs' = do
+        inb <- ask
+        z <- applyRule v xs'
hunk ./E/SSimplify.hs 705
-            (Just (x,xs)) -> didInline inb x xs  -- h x xs inb
+            (Just (x,xs)) -> didInline x xs  -- h x xs inb
hunk ./E/SSimplify.hs 711
-                    didInline inb e xs'
+                    didInline e xs'
hunk ./E/SSimplify.hs 714
-                    didInline inb e xs'
+                    didInline e xs'
hunk ./E/SSimplify.hs 717
-                    didInline inb e xs'
+                    didInline e xs'
hunk ./E/SSimplify.hs 720
-                    didInline inb  e xs'
+                    didInline e xs'
hunk ./E/SSimplify.hs 723
-                    didInline inb  e xs'
+                    didInline e xs'
hunk ./E/SSimplify.hs 728
-    h e xs' inb = do app (e,xs')
-    didInline :: Env -> OutE -> [OutE] -> SM OutE
-    didInline inb z zs = do
+    h e xs' = do app (e,xs')
+    didInline ::OutE -> [OutE] -> SM OutE
+    didInline z zs = do
hunk ./E/SSimplify.hs 771
-    doDs ds inb = do
+    doDs ds = do
hunk ./E/SSimplify.hs 775
-                t'' <- nname t inb
+                t'' <- nname t
hunk ./E/SSimplify.hs 779
-                t' <- nname t inb
+                t' <- nname t
hunk ./E/SSimplify.hs 787
-            w :: [(Id,UseInfo,OutTVr,InE)] -> Env -> [(OutTVr,OutE)] -> SM ([(OutTVr,OutE)],Env)
-            w ((t,UseInfo { useOccurance = Once },t',e):rs) inb ds = do
+            w :: [(Id,UseInfo,OutTVr,InE)] -> [(OutTVr,OutE)] -> SM ([(OutTVr,OutE)],Env)
+            w ((t,UseInfo { useOccurance = Once },t',e):rs) ds = do
hunk ./E/SSimplify.hs 790
-                w rs inb ds -- (minsert t (Susp e sub) sub) inb ds
-            w ((t,n,t',e):rs) inb ds = do
-
+                w rs ds -- (minsert t (Susp e sub) sub) inb ds
+            w ((t,n,t',e):rs) ds = do
+                inb <- ask
hunk ./E/SSimplify.hs 799
-                e' <- f e inb'
+                e' <- localEnv (const inb') $ f e
hunk ./E/SSimplify.hs 804
-                        w rs (insertDoneSubst' t e' . insertInScope (tvrIdent t') ibt $ inb) ((t',e'):ds)
-                    _ -> w rs (insertInScope (tvrIdent t') ibt inb)  ((t',e'):ds)
---                w rs (cacheSubst $ envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) inb) ((t',e'):ds)
-                --w rs (if n /= LoopBreaker then (cacheSubst $ envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) inb) else inb) ((t',e'):ds)
-                --case isAtomic e' && n /= LoopBreaker && t `notMember` exportedSet  of
-                    --True -> do
-                    --    when (n /= Unused) $ mtick $ "E.Simplify.inline.Atomic.{" ++ showName t ++ "}"
-                    --    w rs (insertDoneSubst' t e' . envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) $ inb) ds -- ((t',e'):ds) -- (minsert t (Done e') sub) (envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) inb) ((t',e'):ds)
-                    --False -> w rs (if n /= LoopBreaker then (cacheSubst $ envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) inb) else inb) ((t',e'):ds)
-                --    _ -> w rs (cacheSubst $ envInScope_u (minsert (tvrIdent t') (isBoundTo n e')) inb)  ((t',e'):ds)
-            w [] inb ds = return (ds,inb)
+                        localEnv (insertDoneSubst' t e' . insertInScope (tvrIdent t') ibt) $ w rs  ((t',e'):ds)
+                    _ -> localEnv (insertInScope (tvrIdent t') ibt) $ w rs ((t',e'):ds)
+            w [] ds = ask >>= \inb -> return (ds,inb)
hunk ./E/SSimplify.hs 808
+        inb <- ask
hunk ./E/SSimplify.hs 810
-        (ds',inb') <- w s'  (cacheSubst (envSubst_s sub'' $ envInScope_u (fromList [ (tvrIdent t',NotKnown) | (_,n,t',_) <- s', useOccurance n /= Once] `union`) inb)) []
+        (ds',inb') <- localEnv (envSubst_s sub'' . envInScope_u (fromList [ (tvrIdent t',NotKnown) | (_,n,t',_) <- s', useOccurance n /= Once] `union`)) $ w s' []