Ceres.CeresUtils
Definition map_sum {A B B' : Type} (f : B -> B') (x : A + B) : A + B' :=
match x with
| inl a => inl a
| inr b => inr (f b)
end.
Find an element by key in an association list.
Fixpoint _find_or {A B C} (eqb : A -> A -> bool) (a : A) (xs : list (A * B)) (f : B -> C) (b : C) : C :=
match xs with
| nil => b
| (x, y) :: xs => if eqb a x then f y else _find_or eqb a xs f b
end.
match xs with
| nil => b
| (x, y) :: xs => if eqb a x then f y else _find_or eqb a xs f b
end.
The bind of the sum A monad.