-- trivial body
redBeta env ((x,t):te) b (e:es)
  | inline x e                  = do e' <- redBeta (addEqns env [(x,e)]) te b es
                                     return (bindx e')
  | otherwise                   = liftM (ELet bs) (redBeta env te b es)
  where inline x e              = isSafe x || isEVar e || (value e && finite env e && isSmall e)
        isSafe x                = isEtaExp x || isAssumption x || isCoercion x        
        bindx e'
          | x `elem` evars e'   = ELet bs e'
          | otherwise           = e'
        bs                      = Binds False [(x,t)] [(x,e)]
        isEVar (EVar _)         = True
        isEVar _                = False
redBeta env ((x,t):te) b (e:es)
  | inline x e                  = do e' <- redBeta (addEqns env [(x,e)]) te b es
                                     return (bindx e')
  | otherwise                   = liftM (ELet bs) (redBeta env te b es)
  where inline x e              = isSafe x || isEVar e || (value e && finite env e && isSmall e)
        isSafe x                = isEtaExp x || isAssumption x || isCoercion x        
        bindx e'
          | x `elem` evars e'   = ELet bs e'
          | otherwise           = e'
        bs                      = Binds False [(x,t)] [(x,e)]
        isEVar (EVar _)         = True
        isEVar _                = False
redBeta env ((x,t):te) b (e:es)
  | inline x e                  = do e' <- redBeta (addEqns env [(x,e)]) te b es
                                     return (bindx e')
  | otherwise                   = liftM (ELet bs) (redBeta env te b es)
  where inline x e              = isSafe x || isEVar e || (value e && finite env e && isSmall e)
        isSafe x                = isEtaExp x || isAssumption x || isCoercion x        
        bindx e'
          | x `elem` evars e'   = ELet bs e'
          | otherwise           = e'
        bs                      = Binds False [(x,t)] [(x,e)]
        isEVar (EVar _)         = True
        isEVar _                = False