In singletons-3.0.4
infixr 4 :&:
=> Show (SSigma sig) where
showsPrec p ((sa :: Sing ('WrapSing (sfst :: Sing fst))) :%&: (sb :: Sing snd)) =
showParen (p >= 5) $
showsPrec 5 sa . showString " :&: " . showsPrec 5 sb
Technically this is not wrong, but it's a bit imprecise. :&: is right associative, butShow` instance doesn't use it.
Compare to e.g. Show (NP f xs) from sop-core, where :* is also right associative so it's easy to compare:
infixr 5 :*
instance All (Show `Compose` f) xs => Show (NP f xs) where
showsPrec _ Nil = showString "Nil"
showsPrec d (f :* fs) = showParen (d > 5)
$ showsPrec (5 + 1) f
. showString " :* "
. showsPrec 5 fs
Given the above, I'd rewrite
showsPrec p ((sa :: Sing ('WrapSing (sfst :: Sing fst))) :%&: (sb :: Sing snd)) =
showParen (p > 4) $
showsPrec 5 sa . showString " :&: " . showsPrec 4 sb
I.e. use p > 4 to highlight that it's the 4 as in infixr 4 :&:, and change to showsPrec 4 sb: we don't need to bump precendence level for right argument.
IF there is a reason to prefer "more parentheses" i.e. current version, then it probably should be written in the code as comment.
In
singletons-3.0.4Technically this is not wrong, but it's a bit imprecise.
:&:isright associative, butShow` instance doesn't use it.Compare to e.g.
Show (NP f xs)fromsop-core, where:*is also right associative so it's easy to compare:Given the above, I'd rewrite
I.e. use
p > 4to highlight that it's the4as ininfixr 4 :&:, and change toshowsPrec 4 sb: we don't need to bump precendence level for right argument.IF there is a reason to prefer "more parentheses" i.e. current version, then it probably should be written in the code as comment.