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

Refactor: move pretty-printing and failure code to swarm-util #2155

Merged
merged 9 commits into from
Sep 29, 2024

Conversation

byorgey
Copy link
Member

@byorgey byorgey commented Sep 28, 2024

Swarm.Language.Pretty (in the swarm-lang package) had a bunch of generic pretty-printing infrastructure along with a bunch of specific instances for terms and related things. However, the generic pretty-printing code infrastructure is not specific to swarm-lang. This PR:

  • Moves the generic pretty-printing infrastructure + utilities to Swarm.Pretty in swarm-util to make it more generally applicable.
  • Distributes all the actual PrettyPrec instances to live next to the declarations of the corresponding data types.

In addition, Swarm.Game.Failure (in the swarm-scenario package) also had no dependencies on anything else in swarm-scenario, so this PR also moves it to Swarm.Failure in swarm-util, to make it more generally applicable.

Along the way I also removed DelayType and Prec since they are no longer being used.

byorgey and others added 5 commits September 28, 2024 11:03
Generic pretty-printing infrastructure (`PrettyPrec` class, various
utility functions, etc.) can move to `-util` so we can use it
anywhere, for pretty-printing anything.  All the specific instances
are to be distributed so they live right next to the definitions of
the associated data types.
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Restyled.io <commits@restyled.io>
@byorgey byorgey marked this pull request as ready for review September 28, 2024 16:41
Copy link
Member

@xsebek xsebek left a comment

Choose a reason for hiding this comment

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

Nice, this looks much easier to discover. 👍 I look forward to seeing the haddock in the next release. 🙂

@byorgey
Copy link
Member Author

byorgey commented Sep 28, 2024

I look forward to seeing the haddock in the next release.

That reminds me, I haven't looked at the Haddocks in a long time, probably worth a pass at some point to make sure things are still well-explained, and putting more prominent links to the built Haddock documentation in our materials about "how to contribute".

@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Sep 29, 2024
@mergify mergify bot merged commit 02b151f into main Sep 29, 2024
12 checks passed
@mergify mergify bot deleted the refactor/move-failure branch September 29, 2024 22:04
byorgey added a commit that referenced this pull request Sep 30, 2024
Now that failure stuff has been moved into `swarm-util` as of #2155.
mergify bot pushed a commit that referenced this pull request Sep 30, 2024
Now that `Failure` is moved to `swarm-util` (#2155), that was the last remaining dependency of `Swarm.Game.ResourceLoading` which prevented it from moving as well.  The `ResourceLoading` code is not specific to Swarm scenarios; this PR moves it to `swarm-util` to make it more generally applicable.

In fact, the `ResourceLoading` code is already being used to load `.sw` files when executing the `Run` command; in order to implement #495 we will need to do that loading in order to resolve `import` expressions, but that code will live in `swarm-lang`, which cannot import `swarm-scenario`.
byorgey added a commit that referenced this pull request Sep 30, 2024
Now that failure stuff has been moved into `swarm-util` as of #2155.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants