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

Add top level fromList and toList functions in Cardano.Api.UTxO #767

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

locallycompact
Copy link
Contributor

@locallycompact locallycompact commented Mar 1, 2025

Changelog

- description: |
    Define `fromList` and `toList` in `Cardano.Api.UTxO` module.
# 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
  # - refactoring    # QoL changes
  # - 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

I'd like to add these because the user experience is annoying to have to import GHC.Exts when what I want to say is UTxO.fromList and UTxO.toList (a la Data.Map).

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

@@ -77,3 +77,11 @@ inputSet = Map.keysSet . unUTxO
-- | Remove the right hand side from the left hand side.
difference :: UTxO era -> UTxO era -> UTxO era
difference a b = UTxO $ Map.difference (unUTxO a) (unUTxO b)

-- | Convert from a list of key/value pairs.
fromList :: [(TxIn, TxOut CtxUTxO era)] -> UTxO era
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just reexport GHC.fromList & GHC.toList from this module?

Copy link
Contributor Author

@locallycompact locallycompact Mar 3, 2025

Choose a reason for hiding this comment

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

If it's imported from a qualified module, I think there's something beneficial to seeing the monomorphic type signature in the documentation. Otherwise it seems inconsistent. https://hackage.haskell.org/package/containers-0.4.0.0/docs/Data-Map.html#g: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.

2 participants