aboutsummaryrefslogtreecommitdiff
path: root/src/Util/OptionList.v
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2019-02-11 16:34:03 -0800
committerGravatar Jason Gross <jasongross9@gmail.com>2019-02-11 22:22:46 -0800
commitb06d11d9e12cae00475e8f9a5f69d42cf34ae729 (patch)
tree6f13a3f3c6ccaef28fe6884a677719abe3577ca2 /src/Util/OptionList.v
parent974bb6d7ac3a7f007dd3b8655693f38a54154c2a (diff)
Add Option.{lift,map,combine}, List.Option.lift
These will be useful for extending the AST with `option` types.
Diffstat (limited to 'src/Util/OptionList.v')
-rw-r--r--src/Util/OptionList.v5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Util/OptionList.v b/src/Util/OptionList.v
index c2157346e..4b88dd9a3 100644
--- a/src/Util/OptionList.v
+++ b/src/Util/OptionList.v
@@ -25,6 +25,11 @@ Module Option.
| x :: xs => (x <- x; @bind_list A B xs (fun xs => f (x :: xs)))
end%option%list.
+ Definition lift {A} (ls : list (option A)) : option (list A)
+ := fold_right (fun x xs => x <- x; xs <- xs; Some (x :: xs))%option
+ (Some nil)
+ ls.
+
Module Export Notations.
Notation "A <-- X ; B" := (bind_list X (fun A => B%option)) : option_scope.
End Notations.