Skip to content
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

Add error accumulating function to RefType #75

Closed
fthomas opened this issue Oct 17, 2015 · 8 comments
Closed

Add error accumulating function to RefType #75

fthomas opened this issue Oct 17, 2015 · 8 comments

Comments

@fthomas
Copy link
Owner

fthomas commented Oct 17, 2015

Add a function to RefType that is similar to refine but instead of returning an Either it should return a type that can accumulate errors (something like cats.Validated). bond has this as can be seen here: https://github.com/fthomas/refined/blob/v0.8.2/modules/docs/feature_comparison_bond.md#what-bond-has-but-refined-not

@fthomas
Copy link
Owner Author

fthomas commented Dec 18, 2015

@ysusuk
Copy link
Contributor

ysusuk commented Jun 27, 2017

hi @fthomas, i'll be glad to work on this issue) can you give me some hints on where to start?

@fthomas
Copy link
Owner Author

fthomas commented Jun 27, 2017

That would be great @ysusuk. The easiest way right now to accumulate errors is by using cats' toValidatedNel enhancement for the Either. That way we can write something like this:

(refineV[Positive](x).toValidatedNel |@| refineV[NonEmpty](y).toValidatedNel).map2 {
  (x1, y1) => ???
}

with nice error accumulation. I think my idea was to have a variant of refineV that returns directly a ValidatedNel[String, F[T, P]] instead of an Either[String, F[T, P]]. The easiest way to accomplish this is to copy refineV to the cats module and replace Either with ValidatedNel. If it would have a better name than refineV, that would be nice too. :-)

@ysusuk
Copy link
Contributor

ysusuk commented Jun 29, 2017

hi @fthomas
do you mean as well to create another RefinePartiallyApplie in cats package, that will return ValidatedNel instead of Either?

@fthomas
Copy link
Owner Author

fthomas commented Jul 1, 2017

@ysusuk Yes. :-)

@ysusuk
Copy link
Contributor

ysusuk commented Jul 3, 2017

@fthomas can you pls assign this issue on me)

@fthomas
Copy link
Owner Author

fthomas commented Jul 3, 2017

It seems that I only can assign it to myself.

@fthomas
Copy link
Owner Author

fthomas commented Dec 21, 2017

I'm closing this in favor of #382.

@fthomas fthomas closed this as completed Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants