Created
August 17, 2017 16:52
-
-
Save laduke/fce2732b37a012a4c8f3df57e8ef15cc to your computer and use it in GitHub Desktop.
Maybe to Future
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
// Courtesy https://gitter.im/sanctuary-js/sanctuary | |
// maybeToFuture :: a -> Maybe b -> Future a b | |
const maybeToFuture = S.curry2((x, maybe) => | |
S.maybe(Future.reject(x), Future.of, maybe) | |
); | |
// Collapse a `Future String (Maybe Integer)` into a `Future String Integer`. | |
S.chain(maybeToFuture('parseInt: "XXX" does not represent an integer'), | |
Future.of(S.Nothing)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment