-- |newVars varsToChange a, takes
-- |a list of var ids to change, and an instance of VarsIn and returns
-- |the same VarsIn a with the var ids to change replaced with new ones
-- |from the newids in the state monad.
newVars :: (Monad m, VarsIn a) => Set Idx -> a -> StateT IdxSet m a
newVars varsToChange a = do
  subList <- mapM (\i -> do i' <- newidST 0; return (i, newVar i')) (Data.Set.toList varsToChange)
  return $ applyVarSubsts (fromDisjointList subList) a 
newVars :: (Monad m, VarsIn a) => Set Idx -> a -> StateT IdxSet m a
newVars varsToChange a = do
  subList <- mapM (\i -> do i' <- newidST 0; return (i, newVar i')) (Data.Set.toList varsToChange)
  return $ applyVarSubsts (fromDisjointList subList) a 
newVars varsToChange a = do
  subList <- mapM (\i -> do i' <- newidST 0; return (i, newVar i')) (Data.Set.toList varsToChange)
  return $ applyVarSubsts (fromDisjointList subList) a 