(* -*- coq-prog-args: ("-emacs-U" "-R" "." "Prelude") -*- *) (************************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* ex A | raise : exn -> ex A. Implicit Arguments raise [A]. Program Instance Monad ex := unit A a := val a ; bind A B m f := match m with | val x => f x | raise x => raise x end. Solve Obligations using intros ; destruct x ; auto. Definition try_with A (e : ex A) (catch : exn -> A) : A := match e with | val x => x | raise ex => catch ex end. End Exception_Monad. Notation " 'try' e 'with' f 'end' " := (try_with e f) (at level 50).