[GHC] #7633: Checkable "minimal complete definitions"

GHC ghc-devs at haskell.org
Thu Sep 12 19:27:37 CEST 2013


#7633: Checkable "minimal complete definitions"
-------------------------------------+------------------------------------
        Reporter:  shachaf           |            Owner:
            Type:  feature request   |           Status:  patch
        Priority:  normal            |        Milestone:  7.8.1
       Component:  Compiler          |          Version:  7.6.1
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:  #6028
-------------------------------------+------------------------------------
Changes (by twanvl):

 * status:  new => patch


Comment:

 I found some time to polish the patch. I tried to address the points
 mentioned on this ticket.

 * The pragma is now parsed as a Sig instead of a separate declaration.

 * The minimal complete definitions are now specified with a boolean
 formula. For example
 {{{
 {-# MINIMAL return, ((>>=) | (join,fmap)) #-}
 }}}

 * A warning is generated if the MINIMAL pragma does not cover all methods
 without defaults.

 * I have added documentation to the user_guide.

 * I have added some tests to the testsuite.

 The things I did not do:

 * dmwit sugested that the check should also extend to parent classes. I
 did not implement this, because it would complicate the patch
 significantly. Right now names are resolved locally to a class, and the
 information about whether a method is implemented is also kept per
 instance.

 * simonpj sugested that the check be moved from the typechecker to the
 renamer. However, to check that an instance satisfies the minimal complete
 definition, you need the `Class`. But that is only known after (or during)
 typechecking. The typechecker also does things like collecting default
 implementations. All of that is needed before the minimal complete check
 can be performed. In the end the in `TcInstDcl` check is only a couple of
 lines, I doubt it can be done much simpler.

 Some other remarks:

 * I put the function `defaultClassMinimalDef`, which constructs a default
 minimal complete definition, in `BuildTyCl`. It would be more at home in
 `TcClassDcl`. But there is also a function in vectorize that constructs
 Classes and so it also needs defaultClassMinimalDef.

 * I had to change the interface format. So a full rebuild is needed.

 * It would be nice to include the minimal complete definitions in Haddock
 documentation.

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



More information about the ghc-tickets mailing list