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

Use MonadError for 'LedgerState'. Add Show LedgerState, IOException handling in foldBlocks #422

Merged
merged 1 commit into from Jan 15, 2024

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Jan 10, 2024

Changelog

- description: |
    Use MonadError for 'LedgerState'. Add `Show LedgerState`, `IOException` handling in `foldBlocks`
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
   - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
   - improvement    # QoL changes e.g. refactoring
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

MonadError e m allows to use functions without extra lifting if we need to use them in monad stacks with ExceptT underneath.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

Copy link
Contributor

@smelc smelc left a comment

Choose a reason for hiding this comment

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

Nice API enhancement 👍

@@ -390,9 +396,9 @@ foldBlocks
-- rollback. This is achieved by only calling the accumulator on states/blocks
-- that are older than the security parameter, k. This has the side effect of
-- truncating the last k blocks before the node's tip.
-> ExceptT FoldBlocksError IO a
-> m a
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice change ❤️

I'm not a big fan of those ExceptT return types. Constrained monads like you did is better IMHO.

@carbolymer carbolymer force-pushed the mgalazyn/fix/small-fixes branch 2 times, most recently from b2bbafa to f278cac Compare January 12, 2024 20:50
@carbolymer carbolymer changed the title Add Show LedgerState, IOException handling in foldBlocks Use MonadError for 'LedgerState'. Add Show LedgerState, IOException handling in foldBlocks Jan 12, 2024
@carbolymer carbolymer marked this pull request as ready for review January 12, 2024 20:52
@@ -187,7 +187,7 @@ library internal
, iproute
, memory
, microlens
, mtl
, mtl >= 2.3.1
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want to put this constraint in the other package defined in this (line 319)? Being consistent could avoid surprises later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this constraint is wrong - breaks build with older ghc which require mtl-2.2.2. I've just pushed a compatiblity shim in Cardano.Api.Utils.

@carbolymer carbolymer force-pushed the mgalazyn/fix/small-fixes branch 3 times, most recently from fe4acbe to 3f7b3d8 Compare January 15, 2024 15:06
@carbolymer carbolymer added this pull request to the merge queue Jan 15, 2024
Merged via the queue into main with commit 2b95961 Jan 15, 2024
19 of 20 checks passed
@carbolymer carbolymer deleted the mgalazyn/fix/small-fixes branch January 15, 2024 17:15
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.

None yet

3 participants