[GHC] #15534: Allow associated types in Minimal pragmas

GHC ghc-devs at haskell.org
Wed Aug 22 17:32:44 UTC 2018


#15534: Allow associated types in Minimal pragmas
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.4.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Before we can entertain the thought of extending `MINIMAL` pragmas to
 encompass associated type families, we might want to rethink how we report
 warnings for missing things in classes. Consider this example:

 {{{#!hs
 {-# LANGUAGE TypeFamilies #-}
 module Bug where

 class C a where
   type T1 a
   type T2 a
   m1 :: a
   m2 :: a

 instance C Int
 }}}

 Then the warnings we get are rather fragmented:

 {{{
 $ /opt/ghc/8.4.3/bin/ghci Bug.hs
 GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Bug              ( Bug.hs, interpreted )

 Bug.hs:10:1: warning: [-Wmissing-methods]
     • No explicit associated type or default declaration for ‘T1’
     • In the instance declaration for ‘C Int’
    |
 10 | instance C Int
    | ^^^^^^^^^^^^^^

 Bug.hs:10:1: warning: [-Wmissing-methods]
     • No explicit associated type or default declaration for ‘T2’
     • In the instance declaration for ‘C Int’
    |
 10 | instance C Int
    | ^^^^^^^^^^^^^^

 Bug.hs:10:10: warning: [-Wmissing-methods]
     • No explicit implementation for
         ‘m1’ and ‘m2’
     • In the instance declaration for ‘C Int’
    |
 10 | instance C Int
    |          ^^^^^
 }}}

 Unfortunately, the warnings for missing implementations for associated
 types are completely separate from those for missing implementations for
 methods. This is not an ideal state of affairs, because if we attached the
 following `MINIMAL` pragma to `C`:

 {{{#!hs
   {-# MINIMAL (T1 | m1) | (T2 | m2) #-}
 }}}

 Then presumably, we'd want a single warning to the effect of:

 {{{
     • No explicit implementation for
         either ‘T1’ or ‘m1’, or ‘T2’ or ‘m2’
     • In the instance declaration for ‘C Int’
 }}}

 Achieving this in today's GHC is challenging, since the code for reporting
 warnings for missing associated types lives in `tcATDefault`, whereas the
 code for reporting warnings for missing methods lives in `tcMethods`.
 Perhaps step one is to consolidate these into the same function.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15534#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list