rebuildTE
    :: SyntacticExp f
    => (forall t'. Elt t' => Idx env t' -> f acc env' aenv t')
    -> Tuple (PreOpenExp acc env  aenv) t
    -> Tuple (PreOpenExp acc env' aenv) t
rebuildTE v tup =
  case tup of
    NilTup      -> NilTup
    SnocTup t e -> rebuildTE v t `SnocTup` rebuildE v e
rebuildTE
    :: SyntacticExp f
    => (forall t'. Elt t' => Idx env t' -> f acc env' aenv t')
    -> Tuple (PreOpenExp acc env  aenv) t
    -> Tuple (PreOpenExp acc env' aenv) t
rebuildTE v tup =
  case tup of
    NilTup      -> NilTup
    SnocTup t e -> rebuildTE v t `SnocTup` rebuildE v e
rebuildTE v tup =
  case tup of
    NilTup      -> NilTup
    SnocTup t e -> rebuildTE v t `SnocTup` rebuildE v e