Set Implicit Arguments.
Set Strict Implicit.
Global Instance Foldable_option {T} : Foldable (option T) T :=
fun _ f d v =>
match v with
| None => d
| Some x => f x d
end.
Global Instance Traversable_option : Traversable option :=
{| mapT := fun F _ _ _ f o =>
match o with
| None => pure None
| Some o => ap (pure (@Some _)) (f o)
end
|}.
Global Instance Applicative_option : Applicative option :=
{| pure := @Some
; ap := fun _ _ f x =>
match f , x with
| Some f , Some x => Some (f x)
| _ , _ => None
end
|}.
Global Instance Functor_option : Functor option :=
{| fmap := fun _ _ f x => match x with
| None => None
| Some x => Some (f x)
end |}.
Section relation.
Context {T : Type}.
Variable (R : relation T).
Inductive Roption : Relation_Definitions.relation (option T) :=
| Roption_None : Roption None None
| Roption_Some : forall x y, R x y -> Roption (Some x) (Some y).

Lemma Transitive_Roption : Transitive R -> Transitive Roption.
Global Instance Injective_Roption_None
: Injective (Roption None None).