-
Notifications
You must be signed in to change notification settings - Fork 219
make the type of extract richer #1011
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
make the type of extract richer #1011
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.
Looks great so far! Just a few small suggestions
9fbbae2
to
377968c
Compare
As suggested, i've special-cased the error message for a single error (so that it doesn't change current behaviour). I've added a small message when there are multiple errors, and added an error message for extraction errors. Once we've found a satisfying solution with |
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.
It looks like the stack-lts6.yaml
's extra-deps
section needs newer versions of some dependencies to support the either
/semigroupoids
dependencies
I can drop semigroupoids and use |
b2f391f
to
52a48e2
Compare
I've downgraded deps in stack-lts-6.yaml, but there are still issues with transformers-compat. |
@divarvel: I'll take a look at it tonight to see if I can get it building with |
Thanks! |
Alright, I have a pull request up against your branch that I believe should fix the LTS 6 build failures: divarvel#1 |
Co-Authored-By: Gabriel Gonzalez <[email protected]>
It's not needed anymore, since these values are now wrapped in an ExtractErrors value, which is an Exception itself
cf74352
to
4453bf5
Compare
Thanks a lot! It looks like it's fixed on LTS-6. I've rebased on latest master, so unless something else is missing, I can squash the commits. |
@divarvel: You're welcome! There's no need to rebase or squash ahead of time because the repository settings enforce that we "Squash and merge" anyway when merging pull requests |
See #387 for the whole context. The main idea is to make
extract
return a more detailed errors (currently, it returns aMaybe
).Following discussion with @ocharles, and based on @sellout's comments in the issue, I went with a
Validation (NonEmpty ExtractError)
, whereExtractError
is eitherInvalidType
or a freeform text for user-supplied errors. Reading the tests, the example provided by @sellout seems at odds with the contact thatextract
should only fail on type errors.For now it does not track line number or anything else, but thanks to the applicative instance, it accumulates errors for lists and records. Instead of providing a monad instance through a newtype, I added a
validate
function which is essentially>>=
.I've added dependencies to
either
(forValidation
) and tosemigroupoids
(forData.Functor.Alt
, asNonEmptyList a
only forms a semigroup).ToDo