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

Correct parenthesisation in generic Show #10

Closed
wants to merge 1 commit into from

Conversation

tomjaguarpaw
Copy link
Contributor

This PR fixes a number of issues with the gshow derived in this module

  • Show operators correctly, rather than putting them in quotation marks
  • Don't show spurious I
  • Parenthesise properly (and thus derive gshowsPrec instead of gshow directly)

I appreciate that this package is for "simple basic examples" rather than "fully working but less simple code" but I would question the value of the simple examples if they're just completely wrong for the stated purpose. I think this PR isn't too much more complex than what went before and I think it would be useful to have a real example of Generics.SOP that people can drop in to code that's expected to work.

Anyway, if you really don't want to incorporate this, no hard feelings. I can always create a new package.

Data types

data T = A (Maybe ()) Bool | B Bool

infix 7 :**
data O1 a b = a :** b

infix 6 :++
data O2 a b = a :++ b

data R = MkR1 { r1 :: Maybe (), r2 :: Bool } | MkR2 Bool

Before

A Just () True
I (Just ()) ":**" I (Just ())
I I (Just ()) ":++" I (Just ()) ":**" I I (Just ()) ":++" I (Just ())
I I (Just ()) ":**" I (Just ()) ":++" I I (Just ()) ":**" I (Just ())
MkR1 {r1 = Just (), r2 = True}
Just A Just () True
Just I (Just ()) ":**" I (Just ())
Just MkR1 {r1 = Just (), r2 = True}

After

A (Just ()) True
Just () :** Just ()
(Just () :++ Just ()) :** (Just () :++ Just ())
Just () :** Just () :++ Just () :** Just ()
MkR1 {r1 = Just (), r2 = True}
Just (A (Just ()) True)
Just (Just () :** Just ())
Just MkR1 {r1 = Just (), r2 = True}

This was referenced Nov 8, 2023
@edsko
Copy link
Contributor

edsko commented Nov 8, 2023

Rebased and merged in #12 , and released as https://hackage.haskell.org/package/basic-sop-0.3.0 . Thanks so much!

@edsko edsko closed this Nov 8, 2023
@tomjaguarpaw tomjaguarpaw deleted the Show branch November 8, 2023 10:32
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