Created
July 17, 2015 01:52
-
-
Save yelouafi/c919f3ccc553cfc325cb 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
// anError : Object | |
// mapError : (Stream a, anError -> Stream a) => Stream a | |
Stream.prototype.mapError = function(f) { | |
return this.isEmpty ? this | |
: this.isAbort ? f(this.error) | |
: this.isCons ? Stream.Cons(this.head, this.tail.mapError(f)) | |
: Stream.Future( | |
this.promise.then( | |
s => s.mapError(f), | |
Stream.Abort)) | |
} | |
Stream.Cons(1, Stream.Abort('Error!!')) | |
.mapError(err => Stream.Cons(2, Stream.Empty)) | |
.log() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment