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 Pretty for rendering errors instead of Show #370

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

newhoggy
Copy link
Collaborator

@newhoggy newhoggy commented Nov 15, 2023

Changelog

- description: |
    Use `Pretty` for rendering errors instead of `Show`
# 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

Pretty is a typeclass from the prettyprinter package.

It has support for powerful formatting options such as colour and layout.

By switching to Pretty we are able to use these features. Furthermore, plutus errors and types have Pretty instances so can utilise that to pretty print their error messages in an ergonomic way.

This package is also used by optparse-applicative which means it is already a dependency.

Pretty also doesn't suffer the problem with Show where many of the instances render strings that are not friendly to users.

Ledger also have Show instances that may not behave the way we want.

Our Pretty instances can help us break away from this status quo.

In order to minimise change, this PR does not utilise these features.

Instead, it preserves formatting of all errors exactly as before leaving future PRs to tidy up the formatting and layout of our rendered errors.

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

@newhoggy newhoggy force-pushed the newhoggy/prettyprinter branch 5 times, most recently from 557c682 to 121e558 Compare November 15, 2023 14:01
@newhoggy newhoggy marked this pull request as ready for review November 15, 2023 14:34
Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

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

I like the change, but I have a few remarks.

@newhoggy newhoggy force-pushed the newhoggy/prettyprinter branch from 121e558 to b8d1760 Compare November 16, 2023 09:41
@newhoggy newhoggy force-pushed the newhoggy/prettyprinter branch from b8d1760 to 559978e Compare November 16, 2023 09:55
@newhoggy newhoggy requested a review from carbolymer November 16, 2023 10:03
@newhoggy newhoggy added this pull request to the merge queue Nov 16, 2023
Merged via the queue into main with commit 8091a24 Nov 16, 2023
@newhoggy newhoggy deleted the newhoggy/prettyprinter branch November 16, 2023 13:08
newhoggy pushed a commit that referenced this pull request Mar 11, 2024
…ution-hash

Remove eras' constitution-hash
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.

3 participants