Polymorphic Fixpoint nth_error_get_hlist_nth (ls : list iT) (n : nat) {struct ls} :
    option {t : iT & hlist ls -> F t} :=
    match
      ls as ls0
      return option {t : iT & hlist ls0 -> F t}
    with
      | nil => None
      | l :: ls0 =>
        match
          n as n0
          return option {t : iT & hlist (l :: ls0) -> F t}
        with
          | 0 =>
            Some (@existT _ (fun t => hlist (l :: ls0) -> F t)
                          l (@hlist_hd _ _))
          | S n0 =>
            match nth_error_get_hlist_nth ls0 n0 with
              | Some (existT x f) =>
                Some (@existT _ (fun t => hlist _ -> F t)
                              x (fun h : hlist (l :: ls0) => f (hlist_tl h)))
              | None => None
            end
        end
    end.

Lemma nth_error_get_hlist_nth_weaken : forall ls ls' n x, nth_error_get_hlist_nth ls n = Some x -> exists z, nth_error_get_hlist_nth (ls ++ ls') n = Some (@existT iT (fun t => hlist (ls ++ ls') -> F t) (projT1 x) z) /\ forall h h', projT2 x h = z (hlist_app h h').