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

More Complete Examples for Semigroup and Semiring Validation #16

Closed
jkachmar opened this issue Dec 3, 2017 · 8 comments
Closed

More Complete Examples for Semigroup and Semiring Validation #16

jkachmar opened this issue Dec 3, 2017 · 8 comments

Comments

@jkachmar
Copy link
Contributor

jkachmar commented Dec 3, 2017

I worked out some more complete examples of validations using the Semigroup and Semiring instances today. They're pretty opinionated, but I think having a more completely worked out example in the repository could help newcomers.

Right now they're in a separate repo here, but if this seems like something the maintainers would like, I can clean them up and put them into a proper PR.

@paf31
Copy link
Contributor

paf31 commented Dec 4, 2017

I think it would be great to have an example project in this repo or in the README - thanks for putting this together!

It would be good to try to minimize the dependencies and code as much as possible, I think.

@jkachmar
Copy link
Contributor Author

jkachmar commented Dec 5, 2017

Yeah, the repo was a bit of a rabbit hole for me this weekend to get comfortable with the library 😅.

I'll pare some stuff back and try to PR an example repo soon.

I'm thinking an examples directory with a subdirectory for semigroup-validation and semiring-validation that would provide small, runnable examples that printed some successful/unsuccessful validation results to the console.

@jkachmar
Copy link
Contributor Author

jkachmar commented Dec 6, 2017

How does this look: https://github.com/jkachmar/purescript-validation/tree/feat/add-examples/examples/semigroup ?

If that's good, I can do something similar for Semiring and PR them both.

@chexxor
Copy link

chexxor commented Jan 30, 2018

Yeah, this library is frustrating af without a full-blown explanation of it.

It's questions like:

  • How is different than using Either? (accumulating errors)
  • Why one would want to accumulate errors?
  • How is validation different than parsing? (parsing Foreign vs validating EmailFormattedString)
  • Why not enforce a NonEmpty functor in the error side?
  • How to build a big validator from small, reusable validators? (v1 <> v2 *> resultVal?)
  • How to build small, reusable validators? (why use Unit as result?)
  • What kinds of data types can a validator return? (String vs EmailFormattedString?)

Every time I use this library I get annoyed that I have to validateX someVal *> pure someVal, because someVal is duplicated, which is painful for me to see, and I hate using pure because for me it's a sign that I should just use map.

@hdgarrood
Copy link
Contributor

hdgarrood commented Mar 2, 2020

#17 added examples for the Semigroup version.

@JordanMartinez
Copy link
Contributor

Closed by #17?

@hdgarrood
Copy link
Contributor

This should not be considered closed by #17; that PR only added examples for semigroup validation. Semiring validation is still lacking documentation (although personally, I still think it doesn't deserve to be in core and we should solve that part of the problem by just removing it).

@JordanMartinez
Copy link
Contributor

So #27 would actually close this because it would no longer need to be documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants