cardano-ledger icon indicating copy to clipboard operation
cardano-ledger copied to clipboard

Change applySTS to return NonEmpty (PredicateFailure s)

Open neilmayhew opened this issue 1 year ago • 3 comments

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

  • [x] Commit sequence broadly makes sense and commits have useful messages
  • [x] 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)
  • [x] Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • [x] Cabal files are formatted (use scripts/cabal-format.sh)
  • [x] hie.yaml has been updated (use scripts/gen-hie.sh)
  • [x] Self-reviewed the diff

neilmayhew avatar Feb 15 '24 23:02 neilmayhew

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.

neilmayhew avatar Feb 15 '24 23:02 neilmayhew

Rebased on master and fixed ghc 8.10.7 build

neilmayhew avatar Mar 04 '24 16:03 neilmayhew

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

neilmayhew avatar Mar 07 '24 01:03 neilmayhew