Section RandomFunc.
Variable D R : Set.
Hypothesis D_EqDec : EqDec D.
Hypothesis R_EqDec : EqDec R.
Variable RndR : Comp R.
Hypothesis RndR_wf : well_formed_comp RndR.
(* A random function *)
Definition randomFunc(p : (list (D * R)) * D) : Comp (list (D * R) * R) :=
let (f, d) := p in
match (arrayLookup _ f d) with
| None => (r <-$ RndR; ret ((d, r) :: f, r))
| Some r => ret (f, r)
end.

Lemma randomFunc_wf : forall p,
well_formed_comp (randomFunc p).