-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typed errors #12
Typed errors #12
Conversation
@franciscodr can we invite Jose, and the Kotlin team to review and comment on these PRs as well? |
@nomisRev I have just added the whole Kotlin team, including Jose Gutierrez and Qohat |
Co-authored-by: Francisco Diaz <francisco.d@47deg.com>
Great suggestions, thank you @pakoito 🙌 |
<!--- KNIT example-typed-errors-06.kt --> | ||
<!--- TEST assert --> | ||
|
||
The type system now tracks that a new error of `OtherError` might have occurred, but that we recovered from any possible errors of `MyError`. This is useful across application layers, or in the service layer, where we might want to `recover` from a `DatabaseError` with a `NetworkError` when we want to load data from the network when a database operation failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the article, and it's perfect for showing how to use the API. I think using names like DatabaseError
, NetworkError
etc., would also be suitable for all the examples and perhaps more engaging than the current generic examples like MyError
.
The architectural layer concerns errors that can be used from top to bottom, showing people how to recover and translate errors from one side to the other are close to the problems users face in their real-world projects. We could have a hierarchy like:
ViewError
ModelError
PersistenceError
Or a similar structure that shows how they are handled and translated through layers until the edge over a use case such as login or similar, which requires validation and handling potential failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!.
I just left some minor comments. Feel free to use them or not 😄 .
Co-authored-by: Jose Gutiérrez de Ory <jose.gutierrez@47deg.com>
Co-authored-by: Jose Gutiérrez de Ory <jose.gutierrez@47deg.com>
I'm going to merge this PR, we can improve the domain errors @raulraja but I couldn't find a convenient way to update it in this PR easily without making it a lot longer and involving other concerns. In the Kotlin meeting @franciscodr, @serras and myself discussed adding a page about structuring code. This can perhaps go in the "use-case" section, or another tutorial page explaining layering of applications with typed errors. I think this document serves as the documentation around Feel free to add more comments to this PR after it's closed, and we can turn them into issues/action items. |
This PR adds a draft document for the typed error tutorial. I am not entirely happy with the domain, etc... but I think it covers all the important topics we need to cover in this document.
Sadly with Kotlin 2.0 announced we now that context receivers are still quite some time away, so I didn't mention them on this tutorial which I think should be the backbone of Arrow Core. So be sure to be critical about the domain, examples, and content! And anything missing☺️
Some missing topics, but we probably better to create separate issues for them and collaborate further on this document. Let's brainstorm a list of topics here before turning them into tickets.
zipOrAccumulate
Ior
Option
vsnullable