-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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: Remove (mis)uses of GHC.Show instances #2016
Conversation
I think I get the reasoning for not using But are there any reasons against using custom classes for this purpose? Just two examples from the first commit (preferences):
I think this would make it a bit more concise and clearly show that those functions mentioned above all share a common goal / output. |
True, that's a bit cleaner! I tried to keep it as simple as possible in general, but it makes sense to use typeclasses in this case. Edit: see latest commit with those changes for Preferences. We should do something similar for dumpConfig, but that's for another PR! |
f9f22fd
to
3bf7ed6
Compare
I Like that!
Agreed. This could be something like And then there should be a class for |
3bf7ed6
to
0123c39
Compare
0123c39
to
c1e0dc7
Compare
Many thanks for reviewing @wolfgangwalther ! The FreeBSD build is doing weird things again due to some cache issues, but otherwise this should be good to merge |
This is an item on our refactoring roadmap #1804
Using
GHC.Show
to pretty-print or serialize data is an anti-pattern, show is meant to create a Haskell expression that can be parsed byread
, see https://hackage.haskell.org/package/base-4.16.0.0/docs/GHC-Show.htmlThis PR removes all uses of
GHC.Show
instances in the codebase. As a side effect, this avoids several string conversions, especially when parsing preference headers, for what is likely a small performance gain.