Definition C := ne_tree.T.Definition ret {A: Set}: A -> C A := @ne_tree.Leaf A.Fixpoint bind (A B: Set) (m: C A) (k: A -> C B): C B :=
  match m with
  | ne_tree.Leaf a => k a
  | ne_tree.Node ts => ne_tree.Node (ne_list.map (fun x => bind x k) ts)
  end.Fixpoint lunit A (f: C A) {struct f}: bind f ret = f :=
  match f return bind f ret = f with
  | ne_tree.Leaf x => refl_equal
  | ne_tree.Node l =>
    eq_ind_r (fun l0 => ne_tree.Node l0 = ne_tree.Node l) refl_equal
      ((fix F (l: ne_list.L (C A)) :=
        match l return ne_list.map (fun u => bind u ret) l = l with
        | ne_list.one x => eq_ind_r (fun c => ne_list.one c = ne_list.one x) refl_equal (lunit x)
        | ne_list.cons x y => eq_ind_r (fun c => ne_list.cons c (ne_list.map (fun x => bind x ret) y) = ne_list.cons x y) (eq_ind_r (fun l => ne_list.cons x l = ne_list.cons x y) refl_equal (F y)) (lunit x)
        end) l)
  end.Definition M: Monad := Build_Monad C bind (@ret) runit lunit assoc.

Lemma bind_Node (A B: Set) (x: ne_list.L (ne_tree.T A)) (f: A -> M B): bind (ne_tree.Node x) f = ne_tree.Node (ne_list.map (fun x0: C A => bind x0 f) x).