sweet-monads
sweet-monads copied to clipboard
The library which provides useful monads, interfaces, and lazy iterators.
## Why? Better escape hatch than `.value` ## Usage ```typescript function getUser(id: string): Either; const value = getUser(11).unwrap().name; ``` ## What else - Fixed compiler and linter errors
In js you can override object properties with symbols. TS can add very good type safety for `this` as well. Example for `Maybe` ```typescript class Maybe { // If current...
- Added identity monad - Added tests for identity monad Caveats - Implementation allows multiple parameters (yes, it's not functional style, but convinient. Example - #45) TODO - Docs
All current monads in package are representing some extra state (Left/Right, Just/None), but using monads just for chaining is good on itself Example: ```javascript // Before app.use( express.static( path.resolve(getDirname(import.meta.url), "../public")...
It would be great if the implementation would be compatible with Fantasy Land: https://github.com/fantasyland/fantasy-land
Hello, while @JSMonk was away this spring i created my fork of this library. Here it is https://github.com/AlexXanderGrib/monads-io And here some good ideas you can grab from it: ### 1....
Addresses comment: https://github.com/JSMonk/sweet-monads/pull/53#issuecomment-1494852272
Related to #59
Added breaking changes, which are not necessarily desired: - `Maybe` `from` is always nullable - `Maybe#map` is the same as `.chain(x => fromNullable(fn(x)))` - Added `fold/match` to `Maybe` - Added...
It would be awesome to have a map that caters for nullable values and would return `none` if it's so. At the moment I use ``` just(4).chain(x => fromNullable(add2(x))) ```...