Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves the unwrapping methods for the monads by replacing the old match method with a new fold method and introducing a Foldable interface. Key changes include:
- Replacing match with fold in the Try, Option, and Either monads.
- Updating docs and tests to align with the new fold API.
- Removing the Matchable interface and its related tests, and adding the Foldable module.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/try/try.ts | Replaced match method with fold and updated type definitions to implement Foldable. |
| src/try/try.test.ts | Updated tests to call fold instead of match. |
| src/option/option.ts | Replaced match calls with fold calls and updated the interface accordingly. |
| src/option/option.test.ts | Updated tests to use fold for Option instances. |
| src/match/* | Removed Matchable interface and its tests. |
| src/fold/* | Introduced new Foldable interface and its tests. |
| src/either/either.ts | Updated Either to use fold and removed match references. |
| src/either/either.test.ts | Updated tests to use fold for Either instances. |
| README.md | Updated documentation examples to use fold instead of match. |
Comments suppressed due to low confidence (1)
README.md:112
- There is an extraneous 'm' at the end of the import statement. Please remove the stray character.
import { Either } from '@leanmind/monads';m
There was a problem hiding this comment.
Pull Request Overview
This PR introduces new fold methods in place of the match methods in the Either, Option, and Try monads to provide a more consistent API for unwrapping values. Key changes include replacing former Matchable interfaces with Foldable, updating associated tests, and revising documentation examples.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/try/try.ts | Updated Try monad class and its Success/Failure implementations with fold. |
| src/option/option.ts | Updated Option monad class with fold functionality and revised examples. |
| src/either/either.ts | Replaced match methods with fold in Either and revised related API usage. |
| README.md | Updated documentation to reflect the new fold methods and API changes. |
| Test files (try.test, option.test, either.test, foldable.test) | Revised test cases to use fold instead of match. |
| Removed files in src/match | Eliminated remaining Matchable references in favor of Foldable. |
Comments suppressed due to low confidence (1)
README.md:112
- Stray 'm' character found after the import statement; please remove it to clean up the example code.
import { Either } from '@leanmind/monads';m
BREAKING CHANGE: The Matchable object has been removed. Unwrap must be done using new fold API.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
7958093 to
2697226
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new fold method to replace match in the Either, Option, and Try monads, refactoring monad APIs for a more consistent handling of both sides. It updates the monad implementations, test cases, and documentation accordingly.
- Replaces the match method with fold in Try, Option, and Either.
- Updates test cases and README examples to reflect the new fold API.
- Removes the deprecated Matchable interface and adds a new Foldable interface.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/try/try.ts | Replaces match with fold and updates the static conversion method. |
| src/try/try.test.ts | Adjusts tests to use fold instead of match. |
| src/option/option.ts | Replaces match with fold and updates the static conversion method. |
| src/option/option.test.ts | Adjusts tests to verify fold behavior for Option. |
| src/match/* | Removes the Matchable interface and related test files. |
| src/fold/* | Introduces the Foldable interface and related types and tests. |
| src/either/either.ts | Replaces match with fold and updates the static conversion method. |
| src/either/either.test.ts | Adjusts tests to use fold instead of match for Either. |
| README.md | Updates documentation and examples to reflect the new fold API. |
Comments suppressed due to low confidence (3)
README.md:112
- The import statement contains a trailing 'm', which should be removed to avoid syntax errors.
import { Either } from '@leanmind/monads';m
README.md:293
- There is an extra 'm' at the end of the import statement; please remove it.
import { Option } from '@leanmind/monads';m
README.md:413
- The import statement for Try has an unwanted trailing 'm'; it should be corrected.
import { Try } from '@leanmind/monads';m
|
🎉 This PR is included in version 2.0.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What type of PR is this? (check all applicable)
Description
This pull request introduces significant changes to the
Either,Option, andTrymonads, focusing on replacing thematchmethod with a newfoldmethod for handling both sides of these monads. It also updates the documentation and tests to reflect this change. Additionally, it introduces a newFoldableinterface and refactors theEitherclass to implement it. Below are the most important changes grouped by theme:API Changes to Monads
matchmethod with afoldmethod acrossEither,Option, andTrymonads, providing a more structured and consistent API for handling both sides of these monads. [1] [2] [3] [4] [5] [6]Documentation Updates
README.mdto replace all instances ofmatchwithfold, including examples and descriptions forEither,Option, andTrymonads. [1] [2] [3] [4]Added/updated tests?
We encourage you to keep the quality of the code by creating test.
have not been included