[Haskell-cafe] How to show record syntax?

Duncan Coutts duncan.coutts at googlemail.com
Tue Nov 17 12:46:07 EST 2009

On Tue, 2009-11-17 at 17:14 +0100, Sean Leather wrote:

> > module Main where
> > data A = A {x :: Int} deriving Show
> > main = print $ Just A {x = 5}

> This led to an issue report [3] which developed a few responses. Some
> don't like the grammar as defined, because, at a glance, it appears
> too much like function application. Others noted that Hugs does not
> add the parentheses and wanted to see consistency between compilers.
> In the spirit of the GHC Bug Sweep [4] and finding resolution, I put
> the question to the wider community. How should we show record syntax?
> Should we try to ensure consistency between the compilers? Should we
> try to print as few parentheses as possible? Should we write a
> Haskell' proposal to "fix" the grammar and make Just A {x=5} illegal?
> What do you think?

If you want my opinion, I think consistency between the compilers is
probably a good thing. I do not have a very strong opinion on whether
the derived Show instances should use the extra brackets here or not.
Just pick one. The Show output is not readable in the first place so it
does not really matter.

However I am opposed to "fixing" the grammar to add lots of unnecessary
brackets and to make my programs uglier. Using records for the named
function argument idiom is rather nice and should be encouraged not
discouraged by making the syntax for it worse.

bigChunkyCallWithLotsOfArgs defaultArgs {
    someArg      = 3,
    someOtherArg = 4,


bigChunkyCallWithLotsOfArgs (defaultArgs {
    someArg      = 3,
    someOtherArg = 4,



More information about the Haskell-Cafe mailing list