-
-
Save sgrove/600eeb97a70b4cd6c9b54041281ee503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let default = (value, opt) => | |
switch (opt) { | |
| None => value | |
| Some(value) => value | |
}; | |
let expect = (name, opt) => | |
switch (opt) { | |
| None => raise(Failure("Missing value for " ++ name)) | |
| Some(value) => value | |
}; | |
let map = (opt, update) => | |
switch (opt) { | |
| None => None | |
| Some(value) => Some(update(value)) | |
}; | |
let fmap = (opt, update) => | |
switch (opt) { | |
| None => None | |
| Some(value) => update(value) | |
}; | |
let fmapDefault = (default, opt, update) => | |
switch (opt) { | |
| None => default | |
| Some(value) => update(value) | |
}; | |
let effectMap = (opt, f) => | |
switch (opt) { | |
| None => () | |
| Some(value) => f(value) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment