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

Newconstraints phase3, Add newtypes: Size, SizeSpec and class Sized.

Open TimSheard opened this issue 1 year ago • 0 comments

This is a follow on PR. Originally rebased on top of PR #4120, it is now rebased on the current master, and 4120 has been closed.

Spec does 3 things.

  1. Adds generic size functions on numerous types with HasSpec instances, by adding Sized instances. Current instances include Int, Set, List, Map, and Size itself.
  2. Retracts the And opertor from BoolFn, which turned out to have some technical difficulties.
  3. Adds the methods 'cardinalTypeSpec' and 'cardinalTrueSpec', these allow any HasSpec instance to use the function cardinality :: HasSpec fn t => Spec fn t -> Spec fn Int. It computes bounds on the total number of possible solutions generated by 'genFromTypeSpec' This supports tighter (more accurate) bounds in a number of places.

Checklist

  • [x] 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)
  • [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)
  • [ ] Self-reviewed the diff

TimSheard avatar Feb 27 '24 05:02 TimSheard