-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify Do by removing unwrapping function
- Loading branch information
Showing
14 changed files
with
2,851 additions
and
2,868 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
"ftld": major | ||
--- | ||
|
||
Simplify Do, remove promise support. | ||
|
||
Do no longer needs the unwrapper function. | ||
|
||
``` | ||
// before | ||
const x = Do(function*($) { | ||
const a = yield* $(Result.Ok(1)) | ||
const b = yield* $(Option.Some(2)) | ||
return a + b; | ||
}); | ||
// after | ||
const x = Do(function*() { | ||
const a = yield* Result.Ok(1); | ||
const b = yield* Option.Some(2); | ||
return a + b; | ||
}); | ||
``` | ||
|
||
A side effect of this is that unwrapping promises is no longer supported. This is a breaking change, but it is for the better. | ||
|
||
Promises are not a good fit for the Do notation, and it is better to use async/await instead. Promises also have no way of tracking the Error type, which is a big limitation. |
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
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
Oops, something went wrong.