Minimal Complete Definition Annotations for Haskell

annotations, ghc, haskell

Solution

It looks like this may be in progress.

http://ghc.haskell.org/trac/ghc/ticket/7633 (and related: http://ghc.haskell.org/trac/ghc/ticket/6028)

It looks like it is set to be integrated in GHC 7.8.1.

UPDATE

Here's the minimal pragma in GHC 7.8.

Problem

I defined a NumericPrelude `Ring` instance for my own data type, but failed to define `one` or `fromInteger`. When I compiled the program, I got no warnings because the `Ring` class has default mutually recursive implementations for `one` and `fromInteger`. The result: a stack overflow that was very difficult to find. (Indeed, when using -XRebindableSyntax, the `fromInteger` on numeric constants need not be explicit, so it was quite difficult to figure out `fromInteger` was the culprit of the stack overflow.) Is there a way for developers to annotate classes to indicate a minimal complete definition? It would be very helpful if GHC could throw a warning for instances which do not meet this definition, while allowing a complete set of default implementations. If not, what is the accepted practice here? Should developers leave the (a?) minimal set of methods without defaults so that the appropriate warnings are thrown, or do we rely on users to RTFM?

Original source