diff options
author | Jason Gross <jgross@mit.edu> | 2018-02-10 17:05:22 -0500 |
---|---|---|
committer | Jason Gross <jgross@mit.edu> | 2018-02-10 17:05:22 -0500 |
commit | 06de6db654717314b84deb5692203e11ef504334 (patch) | |
tree | 1fe53b23c5e3c711429952461f2af1b1e9c642d0 /src/Util/Option.v | |
parent | 051ccf4d0666e195c0022c1e5948892bbc7aeca0 (diff) |
Add notation for option_bind
Diffstat (limited to 'src/Util/Option.v')
-rw-r--r-- | src/Util/Option.v | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Util/Option.v b/src/Util/Option.v index a7b9df4e1..a5b19ae4a 100644 --- a/src/Util/Option.v +++ b/src/Util/Option.v @@ -2,6 +2,20 @@ Require Import Coq.Classes.Morphisms. Require Import Coq.Relations.Relation_Definitions. Require Import Crypto.Util.Tactics.BreakMatch. Require Import Crypto.Util.Tactics.DestructHead. +Require Import Crypto.Util.Notations. + +Definition bind {A B} (v : option A) (f : A -> option B) : option B + := match v with + | Some v => f v + | None => None + end. + +Module Export Notations. + Delimit Scope option_scope with option. + Bind Scope option_scope with option. + + Notation "A <- X ; B" := (bind X (fun A => B%option)) : option_scope. +End Notations. Section Relations. Definition option_eq {A} eq (x y : option A) := |