redTopBinds env (bs : bss)      = do Binds r te es <- redBinds env bs
                                     (bss,vs) <- redTopBinds (addEqns env (finiteEqns env es)) bss
                                     let necessary (v,_) = r || maybe (elem v vs) (const True) (fromMod v)
                                         te' = filter necessary te
                                         es' = filter necessary es
                                         bs' = Binds r te' es'
                                         bss' = if null te' then bss else bs':bss
                                     return (bss', idents es' ++ vs)
redTopBinds env (bs : bss)      = do Binds r te es <- redBinds env bs
                                     (bss,vs) <- redTopBinds (addEqns env (finiteEqns env es)) bss
                                     let necessary (v,_) = r || maybe (elem v vs) (const True) (fromMod v)
                                         te' = filter necessary te
                                         es' = filter necessary es
                                         bs' = Binds r te' es'
                                         bss' = if null te' then bss else bs':bss
                                     return (bss', idents es' ++ vs)
redTopBinds env (bs : bss)      = do Binds r te es <- redBinds env bs
                                     (bss,vs) <- redTopBinds (addEqns env (finiteEqns env es)) bss
                                     let necessary (v,_) = r || maybe (elem v vs) (const True) (fromMod v)
                                         te' = filter necessary te
                                         es' = filter necessary es
                                         bs' = Binds r te' es'
                                         bss' = if null te' then bss else bs':bss
                                     return (bss', idents es' ++ vs)