(************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* y " (at level 60, right associativity). Class Alternative `{app : Applicative f} := { (* Operations *) empty : Π {α}, f α ; alternative : Π {α}, f α ---> f α ---> f α where "x <|> y" := (alternative x y) ; (* Properties *) alternative_empty_left : Π {α} (x : f α), empty <|> x == x ; alternative_empty_right : Π {α} (x : f α), x <|> empty == x ; alternative_assoc : Π {α} (x y z : f α), (x <|> y) <|> z == x <|> y <|> z }. (* Binds less than <$>. *) Notation " x <|> y " := (alternative x y). Definition optional `{Alternative f} {a} (v : f a) : f (option_setoid a) := SomeS <$> v <|> pure NoneS. Program Definition optionalS `{Alternative f} {a} : f a ---> f (option_setoid a) := mkMap optional. Next Obligation. simpl_morph. unfold optional. rewrite Hxy. reflexivity. Qed.