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

Change applySTS to return NonEmpty (PredicateFailure s) #4086

Merged
merged 5 commits into from
Mar 7, 2024

Conversation

neilmayhew
Copy link
Contributor

Closes #4054

Description

This eliminates the anomalous possibility of a Left value containing no failures, which we can't treat as a success because it doesn't contain a return value.

I wondered about adding a type alias for NonEmpty (PredicateFailure f) or even Either (NonEmpty (PredicateFailure f)) r to simplify the function type signatures, but decided that would make the code less clear for someone not familiar with the alias.

This touched a lot more lines than I was expecting.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated. If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages. New section is never added with the code changes. (See RELEASING.md)
  • Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • Cabal files are formatted (use scripts/cabal-format.sh)
  • hie.yaml has been updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@neilmayhew neilmayhew requested a review from lehins February 15, 2024 23:00
@neilmayhew neilmayhew force-pushed the neilmayhew/nonempty-predicate-failures branch from 1c2794b to d551071 Compare February 15, 2024 23:06
@neilmayhew
Copy link
Contributor Author

neilmayhew commented Feb 15, 2024

The ghc 8.10.7 builds are failing because there's no singleton in Data.List.NonEmpty. I assume you'll want us to fix this.

I could fix it by using fromList, turning on OverloadedLists, using CPP to conditionally define a singleton function, or construct singletons explicitly with :| [].

All the uses of NE.singleton are in test code, so the partiality of using fromList (directly, or via OverloadedLists) won't matter.

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from required changes to versions and changelogs this PR looks great.

@neilmayhew neilmayhew force-pushed the neilmayhew/nonempty-predicate-failures branch from d551071 to 4223cd4 Compare March 2, 2024 00:07
@neilmayhew
Copy link
Contributor Author

Rebased on master and fixed ghc 8.10.7 build

@neilmayhew neilmayhew force-pushed the neilmayhew/nonempty-predicate-failures branch from 4223cd4 to 2a2d53a Compare March 7, 2024 01:28
@neilmayhew
Copy link
Contributor Author

I rebased, but kept the review changes as separate commits. I'll squash before merging.

@lehins lehins force-pushed the neilmayhew/nonempty-predicate-failures branch from 2a2d53a to 7f09bcc Compare March 7, 2024 10:18
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful!!
Thank you.

@lehins lehins enabled auto-merge (squash) March 7, 2024 11:37
@lehins lehins merged commit e8c6750 into master Mar 7, 2024
16 checks passed
@neilmayhew neilmayhew deleted the neilmayhew/nonempty-predicate-failures branch March 7, 2024 14:22
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

Successfully merging this pull request may close these issues.

Change applySTS to return NonEmpty (PredicateFailure s)
2 participants