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

Accumulate errors a la Validation #103

Open
LeifW opened this issue May 20, 2014 · 6 comments
Open

Accumulate errors a la Validation #103

LeifW opened this issue May 20, 2014 · 6 comments

Comments

@LeifW
Copy link

LeifW commented May 20, 2014

If I have case class Person(name: String, age: Int), and then I run Parse.decode[Person]("{}"}), I want "missing fields: name, age", not just "missing field: name"

Like maybe a cursor variant that returns Validation not /, so one could write a Decode instance like ((c --\ "name").as[String] |@| (c --\ "age").as[Int])(Person), to get notified of both fields missing?

@LeifW
Copy link
Author

LeifW commented May 20, 2014

Like maybe a variant that uses ^ on Validations rather than flatMap on /'s here- https://github.com/argonaut-io/argonaut/blob/master/src/main/scala/argonaut/ACursor.scala#L116

@markhibberd
Copy link
Contributor

We should be able to do this. It might take a fair bit to not break the current style, but I thing it is doable and worth it. There is a pattern by which you can build an applicative structure using a CPS'd reader that would give you the behavior even for current flatMap style.

Also now is probably a good time to do it. We will have to make a few incompatible changes for 6.1 as anyway.

@ritschwumm
Copy link

the CPSed reader sounds interesting, do you know where i could find a description of this technique?

@markhibberd
Copy link
Contributor

@eirirlar
Copy link

This is a really nice feature that I miss a lot - any plans on incorporating this in argonaut-6.1?

@seanparsons
Copy link
Member

@eirirlar Well if it were to make it into a release it would be 6.2, but since the core lib in that doesn't depend on Scalaz at the very least it wouldn't be Validation.

As far as doing this without that it's probably still possible.

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

5 participants