diff options
author | Jason Gross <jagro@google.com> | 2018-06-21 17:06:33 -0400 |
---|---|---|
committer | Jason Gross <jagro@google.com> | 2018-06-21 17:06:33 -0400 |
commit | c8cd6ec125ed7cd9b0b9518d195c1df4f4411115 (patch) | |
tree | 75a3093549318ffccaf4bec3dd9eda4066b0e0a0 /src/Util/OptionList.v | |
parent | dfbdd15176a1d50ffc5468bb066a18b1bd539588 (diff) |
Add Option.List.bind_list
Diffstat (limited to 'src/Util/OptionList.v')
-rw-r--r-- | src/Util/OptionList.v | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Util/OptionList.v b/src/Util/OptionList.v index 57cc52f06..2f6d8a2ce 100644 --- a/src/Util/OptionList.v +++ b/src/Util/OptionList.v @@ -1,3 +1,4 @@ +Require Import Crypto.Util.Option. Require Import Crypto.Util.Notations. Module Option. @@ -16,5 +17,17 @@ Module Option. end end. End map. + + Fixpoint bind_list {A B} (v : list (option A)) (f : list A -> option B) : option B + := match v with + | nil => f nil + | x :: xs => (x <- x; @bind_list A B xs (fun xs => f (x :: xs))) + end%option%list. + + Module Export Notations. + Notation "A <-- X ; B" := (bind_list X (fun A => B%option)) : option_scope. + End Notations. End List. End Option. + +Export Option.List.Notations. |