-
Notifications
You must be signed in to change notification settings - Fork 4
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
Use String instead of ExactError #25
base: main
Are you sure you want to change the base?
Conversation
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.
This is a good simplification 👍The ExactError
was pretty useless
I'm not a fan of using Strings as an error representation. It means translation must happen in the domain layer, which I don't think is right. I think it would be better if it was possible for users to declare their own error types. |
Hi @CLOVIS-AI , it's possible we have In the case where the user is too lazy to define a custom error - what's the benefit of wrapping a |
I think there was probably some confusion here indeed. fun interface Exact<Input, Output> : ExactEither<String, Input, Output> but it should probably just be: typealias Exact<Input, Output> : ExactEither<String, Input, Output> I am not a huge fan of the name |
I had similar idea, but the only thing that stopped me is a returned But maybe it is a matter of learning and getting used to the library. Btw, class ExactError<T>(val error: String, val value: T)
val value = "1235123"
Name.from(value).mapLeft {
NotName(it.value) // NotName("1235123")
} |
We can mimic In that case clients won't need to construct
Using 1 and 2 will allow clients to write less boilerplate code and we will have a type that states clear that we deal with an error, not a generic string (we are a library about concrete types after all 😄 ). I would also suggest:
|
No description provided.