Global Instance Foldable_list {T} : Foldable (list T) T :=
fun _ f x ls => fold_right f x ls.
Section traversable.
Polymorphic Context {F : Type -> Type}.
Polymorphic Context {Applicative_F : Applicative F}.
Polymorphic Context {A B : Type}.
Polymorphic Variable f : A -> F B.
Polymorphic Fixpoint mapT_list (ls : list A) : F (list B) :=
match ls with
| nil => pure nil
| l :: ls => ap (ap (pure (@cons B)) (f l)) (mapT_list ls)
end.
End traversable.
Global Instance Traversable_list : Traversable list :=
{ mapT := @mapT_list }.
Global Instance Monad_list : Monad list :=
{ ret  := fun _ x => x :: nil
; bind := fun _ _ x f =>
List.fold_right (fun x acc => f x ++ acc) nil x
}.
Section list.
Inductive R_list_len {T} : list T -> list T -> Prop :=
| R_l_len : forall n m, length n < length m -> R_list_len n m.

Theorem wf_R_list_len T : well_founded (@R_list_len T).
End ListEq.