Section RandomFunc.
Variable D R : Set.
Variable RndR : Comp R.
Hypothesis EqDec_D : EqDec D.
Instance EqDec_R : EqDec R.
eapply comp_EqDec.
eauto.
Qed.
Hypothesis RndR_wf : well_formed_comp RndR.
(* A random function *)
Definition randomFunc (f : (list (D * R))) (d : D) : Comp (R * list (D * R)) :=
match (arrayLookup _ f d) with
| None => (r <-$ RndR; ret (r, (d, r) :: f))
| Some r => ret (r, f)
end.

Lemma randomFunc_wf : forall f d,
well_formed_comp (randomFunc f d).