Add Option.force_msg (#328)

* Add Option.force_msg

* CHANGELOG update
This commit is contained in:
Radosław Rowicki
2021-08-03 11:39:53 +02:00
committed by GitHub
parent b20b9c5df5
commit 4896ad3b36
3 changed files with 18 additions and 1 deletions
+6
View File
@@ -26,6 +26,12 @@ namespace Option =
None => abort("Forced None value")
Some(x) => x
/** Assume it is `Some` with custom error message
*/
function force_msg(o : option('a), err : string) : 'a = switch(o)
None => abort(err)
Some(x) => x
function contains(e : 'a, o : option('a)) = o == Some(e)
function on_elem(o : option('a), f : 'a => unit) : unit = match((), f, o)