Closed hdgarrood closed 8 years ago
Note that this Show
instance isn't entirely faithful, as it pretends that the thunks (Unit -> a
) are not there, but it's still very useful IMO. Example output:
SigProd "Test.Main.TupleArray" [ { sigConstructor: "Test.Main.TupleArray", sigValues: [ SigArray (SigProd "Data.Tuple.Tuple" [ { sigConstructor: "Data.Tuple.Tuple", sigValues: [ SigInt, SigString ]} ]) ]} ]
:+1: Looks good. Do you want to have a go at the parens fix? No worries if not, I can merge this either way.
Oh yeah sure - I guess if sig is a SigProd, SigRecord, or SigArray, then we need parens here, and otherwise we don't?
I had a go at the parens thing. How does this look?
Looks good, thanks!
I usually break these into two functions, like typeAsBox
and typeAtomAsBox
in Language.PureScript.Pretty.Types
, where "atom" means something that doesn't need to be wrapped in parens. The showsPrec
way is to have a family of functions parameterized by an integer argument representing the current precedence level, but we only have two levels here.
Could you please squash commits and ping me, and I'll get this merged in.
Squashed.
Thanks!
Released as v0.7.2
Also a Show GenericSignature instance which uses showSignature. This can be very useful for diagnosing issues such as the one mentioned in https://github.com/paf31/purescript-foreign-generic/pull/10