Add flag to make derived Show instance use function application instead of record syntax.
E.g. given a type
newtype Max a = Max { getMax :: a } deriving (Show, Read)
>>> Max 'x'
Max {getMax = 'x'}
The record syntax is overly verbose, I'd prefer in these cases to have output to be just Max 'x'
.
Perfectly, this would be possible to toggle per derived instance; module global flag is a least intrusive change (no need to figure out "syntax" to tweak each derived instance; there some future-proof solution may be desirable to be able to tweak derived instances in more ways).
This would require changing generated Read
instances too, as constructor syntax is not accepted:
>>> read "Max 'x'" :: Max Char
Max {getMax = *** Exception: Prelude.read: no parse
which is unfortunate. And maybe worth changing even if it's not possible to tweak derived Show
instance.
This is partly motivated by the fact that base
's own documentation uses First 0
like syntax in its examples:
-- >>> First 0 <> First 10
-- First 0
which is a slight lie. Actually ghci will print First {getFirst = 0}
.