GHC: Ticket #5542: also parse class/instance declarations as "HEAD <= CONTEXT where"
http://ghc.haskell.org/trac/ghc/ticket/5542
<p>
When looking at a list of instance declarations, it can be difficult to visually locate the instance heads. In particular, the varying size of the contexts means that it's difficult to align the instance heads without introducing extraneous white-space.
</p>
<p>
I suggest allowing the head to come first (like all other declarations), so that the varying context lengths no longer prevent easy identification of the class/instance heads.
</p>
<p>
For example, I think it's easier to see which instances are being declared in this following list of (,) instances
</p>
<pre class="wiki">instance Bounded (a, b) <= (Bounded a, Bounded b) where …
instance Eq (a, b) <= (Eq a, Eq b) where …
instance Functor ((,) a) where …
instance Ord (a, b) <= (Ord a, Ord b) where …
instance Read (a, b) <= (Read a, Read b) where …
instance Show (a, b) <= (Show a, Show b) where …
</pre><p>
than it is with the default syntax
</p>
<pre class="wiki">instance (Bounded a, Bounded b) => Bounded (a, b) where …
instance (Eq a, Eq b) => Eq (a, b) where …
instance Functor ((,) a) where …
instance (Ord a, Ord b) => Ord (a, b) where …
instance (Read a, Read b) => Read (a, b) where …
instance (Show a, Show b) => Show (a, b) where …
</pre><p>
A more compelling example would involve multiparameter type classes and juxtaposition of instances for different combinations of types.
</p>
<p>
(Bonus: the proposed ordering might even help beginner grasp that the instance context is not used for instance selection.)
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/5542
Trac 1.2porgesWed, 12 Oct 2011 09:26:51 GMT
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:1
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:1
<p>
I just added <= as a reserved word into Lexer.x and then in Parser.y duplicated all mentions of => with <= as well. Doing this adds about 10 shift/reduce conflicts and 5 or so reduce/reduce conflicts.
</p>
<p>
It does compile and work, but things like this make GHC panic:
</p>
<blockquote>
<p>
instance Show a => Foo a <= Show a where
</p>
</blockquote>
<p>
:)
</p>
TicketiglooSat, 12 Nov 2011 00:29:11 GMTmilestone set
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:2
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:2
<ul>
<li><strong>milestone</strong>
set to <em>7.6.1</em>
</li>
</ul>
TicketsimonpjMon, 14 Nov 2011 22:20:55 GMT
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:3
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:3
<p>
If you can find lots of people who Really Really Want this, maybe. But however sensible in principle, it's hard to justify yet another syntactic form. I'm pretty dubious.
</p>
TicketiglooWed, 12 Sep 2012 11:12:05 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:4
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:4
<ul>
<li><strong>milestone</strong>
changed from <em>7.6.1</em> to <em>7.6.2</em>
</li>
</ul>
TicketthoughtpoliceMon, 14 Jul 2014 13:04:47 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:5
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:5
<ul>
<li><strong>milestone</strong>
changed from <em>7.6.2</em> to <em>7.10.1</em>
</li>
</ul>
<p>
Moving to 7.10.1.
</p>
TicketthoughtpoliceTue, 23 Dec 2014 13:34:10 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:6
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:6
<ul>
<li><strong>milestone</strong>
changed from <em>7.10.1</em> to <em>7.12.1</em>
</li>
</ul>
<p>
Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.
</p>
TicketthomieFri, 03 Jul 2015 11:21:50 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:7
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:7
<ul>
<li><strong>milestone</strong>
changed from <em>7.12.1</em> to <em>⊥</em>
</li>
</ul>
<p>
Please try to get support for this feature on one of the mailing lists first. See also: <a class="wiki" href="http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/AddingFeatures">WorkingConventions/AddingFeatures</a>.
</p>
TicketthomieFri, 03 Jul 2015 11:22:06 GMTstatus changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:8
http://ghc.haskell.org/trac/ghc/ticket/5542#comment:8
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>invalid</em>
</li>
</ul>
Ticket