Show instance for SrcSpan

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Alan & Kim Zimmerman
Is there any reason I can't put in a diff request to replace the derived
Show instance for SrcSpan with a handcrafted one that does not exhausively
list the constructors, making it more readable?

Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141006/c234eed1/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Mateusz Kowalczyk
On 10/06/2014 01:59 PM, Alan & Kim Zimmerman wrote:
> Is there any reason I can't put in a diff request to replace the derived
> Show instance for SrcSpan with a handcrafted one that does not exhausively
> list the constructors, making it more readable?
>
> Alan
>

Why? If you're looking for pretty output then you should be changing
Outputable.


--
Mateusz K.

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Johan Tibell-2
Aside: I really miss derived Show instances in GHC. The Outputable class is
only really useful if you already know how things work. If you e.g. want to
see the AST used to represent some piece of Haskell code, in all its glory,
the Outputable instances aren't useful because they elide too much
information.

On Mon, Oct 6, 2014 at 3:11 PM, Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
wrote:

> On 10/06/2014 01:59 PM, Alan & Kim Zimmerman wrote:
> > Is there any reason I can't put in a diff request to replace the derived
> > Show instance for SrcSpan with a handcrafted one that does not
> exhausively
> > list the constructors, making it more readable?
> >
> > Alan
> >
>
> Why? If you're looking for pretty output then you should be changing
> Outputable.
>
>
> --
> Mateusz K.
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://www.haskell.org/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141006/a9dda448/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Alan & Kim Zimmerman
In reply to this post by Mateusz Kowalczyk
True, but if you are using GHC generated stuff via the GHC API you
sometimes do not want to have to implement Outputable for all your app
types, when you can auto derive Show which mostly does what you need.

On Mon, Oct 6, 2014 at 3:11 PM, Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
wrote:

> On 10/06/2014 01:59 PM, Alan & Kim Zimmerman wrote:
> > Is there any reason I can't put in a diff request to replace the derived
> > Show instance for SrcSpan with a handcrafted one that does not
> exhausively
> > list the constructors, making it more readable?
> >
> > Alan
> >
>
> Why? If you're looking for pretty output then you should be changing
> Outputable.
>
>
> --
> Mateusz K.
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://www.haskell.org/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141006/78e1f14d/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Matthias Fischmann-3
In reply to this post by Alan & Kim Zimmerman
On Mon, Oct 06, 2014 at 02:59:03PM +0200, Alan & Kim Zimmerman wrote:

> Date: Mon, 6 Oct 2014 14:59:03 +0200
> From: Alan & Kim Zimmerman <alan.zimm at gmail.com>
> To: "ghc-devs at haskell.org" <ghc-devs at haskell.org>
> Subject: Show instance for SrcSpan
>
> Is there any reason I can't put in a diff request to replace the derived
> Show instance for SrcSpan with a handcrafted one that does not exhausively
> list the constructors, making it more readable?
>
> Alan


I like the notion that `Read . Show` should always work.  Dropping
parts of a datatype would break that rule.

matthias

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Alan & Kim Zimmerman
Not at all, just show as e.g.

  SrcSpan (RealSrcSpan (SrcSpanOneLine "./foo.hs" 4 1 6))

We just avoid showing the srcSpanFile / srcSpanLine / srcSpanSCol /
srcSpanECol noise


On Mon, Oct 6, 2014 at 3:16 PM, Matthias Fischmann <mf at zerobuzz.net> wrote:

> On Mon, Oct 06, 2014 at 02:59:03PM +0200, Alan & Kim Zimmerman wrote:
> > Date: Mon, 6 Oct 2014 14:59:03 +0200
> > From: Alan & Kim Zimmerman <alan.zimm at gmail.com>
> > To: "ghc-devs at haskell.org" <ghc-devs at haskell.org>
> > Subject: Show instance for SrcSpan
> >
> > Is there any reason I can't put in a diff request to replace the derived
> > Show instance for SrcSpan with a handcrafted one that does not
> exhausively
> > list the constructors, making it more readable?
> >
> > Alan
>
>
> I like the notion that `Read . Show` should always work.  Dropping
> parts of a datatype would break that rule.
>
> matthias
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://www.haskell.org/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141006/c28a4d8a/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Matthias Fischmann-3

Ah, you want to drop constructor field names.  Then I withdraw my
reservations.

thanks for the clarification,
m.



On Mon, Oct 06, 2014 at 03:27:49PM +0200, Alan & Kim Zimmerman wrote:

> Date: Mon, 6 Oct 2014 15:27:49 +0200
> From: Alan & Kim Zimmerman <alan.zimm at gmail.com>
> To: Matthias Fischmann <mf at zerobuzz.net>
> Cc: "ghc-devs at haskell.org" <ghc-devs at haskell.org>
> Subject: Re: Show instance for SrcSpan
>
> Not at all, just show as e.g.
>
>   SrcSpan (RealSrcSpan (SrcSpanOneLine "./foo.hs" 4 1 6))
>
> We just avoid showing the srcSpanFile / srcSpanLine / srcSpanSCol /
> srcSpanECol noise
>
>
> On Mon, Oct 6, 2014 at 3:16 PM, Matthias Fischmann <mf at zerobuzz.net> wrote:
>
> > On Mon, Oct 06, 2014 at 02:59:03PM +0200, Alan & Kim Zimmerman wrote:
> > > Date: Mon, 6 Oct 2014 14:59:03 +0200
> > > From: Alan & Kim Zimmerman <alan.zimm at gmail.com>
> > > To: "ghc-devs at haskell.org" <ghc-devs at haskell.org>
> > > Subject: Show instance for SrcSpan
> > >
> > > Is there any reason I can't put in a diff request to replace the derived
> > > Show instance for SrcSpan with a handcrafted one that does not
> > exhausively
> > > list the constructors, making it more readable?
> > >
> > > Alan
> >
> >
> > I like the notion that `Read . Show` should always work.  Dropping
> > parts of a datatype would break that rule.
> >
> > matthias
> > _______________________________________________
> > ghc-devs mailing list
> > ghc-devs at haskell.org
> > http://www.haskell.org/mailman/listinfo/ghc-devs
> >

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Alan & Kim Zimmerman
To get even more heretical, a quick grep of the compiler source tree does
not show

    SrcSpanOneLine / SrcSpanMultiLine / SrcSpanPoint

being used anywhere but in SrcLoc.lhs.

The use in SrcLoc is in the original constructor, the deconstructors
pulling out lines and columns, and combineSrcSpans.

Perhaprs our SrcSpan is more complicated than it needs to be?

On Mon, Oct 6, 2014 at 3:37 PM, Matthias Fischmann <mf at zerobuzz.net> wrote:

>
> Ah, you want to drop constructor field names.  Then I withdraw my
> reservations.
>
> thanks for the clarification,
> m.
>
>
>
> On Mon, Oct 06, 2014 at 03:27:49PM +0200, Alan & Kim Zimmerman wrote:
> > Date: Mon, 6 Oct 2014 15:27:49 +0200
> > From: Alan & Kim Zimmerman <alan.zimm at gmail.com>
> > To: Matthias Fischmann <mf at zerobuzz.net>
> > Cc: "ghc-devs at haskell.org" <ghc-devs at haskell.org>
> > Subject: Re: Show instance for SrcSpan
> >
> > Not at all, just show as e.g.
> >
> >   SrcSpan (RealSrcSpan (SrcSpanOneLine "./foo.hs" 4 1 6))
> >
> > We just avoid showing the srcSpanFile / srcSpanLine / srcSpanSCol /
> > srcSpanECol noise
> >
> >
> > On Mon, Oct 6, 2014 at 3:16 PM, Matthias Fischmann <mf at zerobuzz.net>
> wrote:
> >
> > > On Mon, Oct 06, 2014 at 02:59:03PM +0200, Alan & Kim Zimmerman wrote:
> > > > Date: Mon, 6 Oct 2014 14:59:03 +0200
> > > > From: Alan & Kim Zimmerman <alan.zimm at gmail.com>
> > > > To: "ghc-devs at haskell.org" <ghc-devs at haskell.org>
> > > > Subject: Show instance for SrcSpan
> > > >
> > > > Is there any reason I can't put in a diff request to replace the
> derived
> > > > Show instance for SrcSpan with a handcrafted one that does not
> > > exhausively
> > > > list the constructors, making it more readable?
> > > >
> > > > Alan
> > >
> > >
> > > I like the notion that `Read . Show` should always work.  Dropping
> > > parts of a datatype would break that rule.
> > >
> > > matthias
> > > _______________________________________________
> > > ghc-devs mailing list
> > > ghc-devs at haskell.org
> > > http://www.haskell.org/mailman/listinfo/ghc-devs
> > >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141006/c9a4ac85/attachment-0001.html>

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

p.k.f.holzenspies@utwente.nl
In reply to this post by Alan & Kim Zimmerman
The way I read Alan's earlier mail is precisely that; auto-generated Show does what he wants (show the entire AST), whereas Outputable hides too much information. I very much understand his frustration with having to manually figure out what constructors and datatypes go where in a compiled program. Alan's point was the *absence* of auto derived Show instances and, in the case of SrcSpan, too much verbosity (rather than wanting stuff to be incomplete).


Allowing some bespoke stuff to reduce the noise of something like record field names for SrcSpan makes even more sense in this context. Similarly, this is why Alan & I want everything to have Data instances, so you can (amongst many other nice things) selectively print parts of the AST.


Ph.




________________________________
From: Alan & Kim Zimmerman <alan.zimm at gmail.com>
Sent: 06 October 2014 15:15
To: Mateusz Kowalczyk
Cc: ghc-devs at haskell.org
Subject: Re: Show instance for SrcSpan

True, but if you are using GHC generated stuff via the GHC API you sometimes do not want to have to implement Outputable for all your app types, when you can auto derive Show which mostly does what you need.

On Mon, Oct 6, 2014 at 3:11 PM, Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk<mailto:fuuzetsu at fuuzetsu.co.uk>> wrote:
On 10/06/2014 01:59 PM, Alan & Kim Zimmerman wrote:
> Is there any reason I can't put in a diff request to replace the derived
> Show instance for SrcSpan with a handcrafted one that does not exhausively
> list the constructors, making it more readable?
>
> Alan
>

Why? If you're looking for pretty output then you should be changing
Outputable.


--
Mateusz K.
_______________________________________________
ghc-devs mailing list
ghc-devs at haskell.org<mailto:ghc-devs at haskell.org>
http://www.haskell.org/mailman/listinfo/ghc-devs

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141006/e49c4c39/attachment.html>

Reply | Threaded
Open this post in threaded view
|

Show instance for SrcSpan

Simon Peyton Jones
In reply to this post by Alan & Kim Zimmerman
By all means do so

S

From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Alan & Kim Zimmerman
Sent: 06 October 2014 13:59
To: ghc-devs at haskell.org
Subject: Show instance for SrcSpan

Is there any reason I can't put in a diff request to replace the derived Show instance for SrcSpan with a handcrafted one that does not exhausively list the constructors, making it more readable?
Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20141006/f036ca76/attachment.html>