declaring minimal complete instance definition (was: 2014 Applicative => Monad proposal)

Shachaf Ben-Kiki shachaf at gmail.com
Thu May 23 22:20:39 CEST 2013


On Thu, May 23, 2013 at 4:17 PM, Herbert Valerio Riedel <hvr at gnu.org> wrote:
> As this is a general problem which comes up often with mutually
> recursive default implementations for typeclass methods, I have been
> wondering if somebody came up with a solution for that, which allows the
> compiler to emit warnings or even errors.
>
> Often the documentation for a typeclass already specifies the "minimal
> complete definition", if this could be meta-annotated with some pragma
> for the compiler to pick up, we could have the compiler help us avoid
> invalid instance definition. Has some ghc-feature/extension to this
> effect been discussed in the past?
>
>
> Btw, even the simple 'Eq' and 'Ord' classes have mutually depending
>     default implementations:
>
>  - Eq: "Minimal complete definition: either '==' or '/='."
>
>  - Ord: "Minimal complete definition: either 'compare' or '<='. Using
>         'compare' can be more efficient for complex types."
>
> cheers,
>   hvr
>

See my proposal along these lines from a few months ago to implement
this as a pragma in GHC:

http://hackage.haskell.org/trac/ghc/ticket/7633

    Shachaf



More information about the Libraries mailing list