proposition: Lemma qperm_preserves_size2 A (x : seq A) B (f : seq A -> nat -> M B) : (qperm x >>= f^~ (size x)) = qperm x >>= (fun x' => f x' (size x')) :> M _.
proof: Proof. transitivity (qperm x >>= (fun y => Ret (y, size y)) >>= (fun x' => f x'.1 x'.2)). by rewrite qperm_preserves_size bindA; bind_ext => s; rewrite bindretf. by rewrite bindA; bind_ext => s; rewrite bindretf. Qed.
imports: mathcomp(all_ssreflect) monae_lib HB(structures) hierarchy monad_lib Equations(Equations)