#5542: also parse class/instance declarations as "HEAD <= CONTEXT where"
---------------------------------+------------------------------------------
    Reporter:  nfrisby           |       Owner:                   
        Type:  feature request   |      Status:  new              
    Priority:  normal            |   Component:  Compiler (Parser)
     Version:  7.2.1             |    Keywords:                   
    Testcase:                    |   Blockedby:                   
          Os:  Unknown/Multiple  |    Blocking:                   
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown     
---------------------------------+------------------------------------------
 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.

 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.

 For example, I think it's easier to see which instances are being declared
 in this following list of (,) instances

 {{{
 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 …
 }}}

 than it is with the default syntax

 {{{
 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 …
 }}}

 A more compelling example would involve multiparameter type classes and
 juxtaposition of instances for different combinations of types.

 (Bonus: the proposed ordering might even help beginner grasp that the
 instance context is not used for instance selection.)

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5542>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to