Section hlist_gen.
Variable A : Type.
Variable F : A -> Type.
Variable f : forall a, F a.
Fixpoint hlist_gen ls : hlist F ls :=
match ls with
| nil => Hnil
| cons x ls' => Hcons (f x) (hlist_gen ls')
end.
(** This function is a generalisation of [hlist_gen] in which the function [f] takes the additional parameter [member a ls]. **)
Fixpoint hlist_gen_member ls : (forall a, member a ls -> F a) -> hlist F ls :=
match ls as ls return ((forall a : A, member a ls -> F a) -> hlist F ls) with
| nil => fun _ => Hnil
| a :: ls' => fun fm =>
Hcons (fm a (MZ a ls'))
(hlist_gen_member (fun a' (M : member a' ls') => fm a' (MN a M)))
end.

Lemma hlist_gen_member_ext : forall ls (f g : forall a, member a ls -> F a),
(forall x M, f x M = g x M) ->
hlist_gen_member f = hlist_gen_member g.