Redundant constraints
Ross Paterson
R.Paterson at city.ac.uk
Thu Jan 8 17:25:38 UTC 2015
On Wed, Jan 07, 2015 at 03:19:15PM +0000, Simon Peyton Jones wrote:
> I’ve pushed a big patch that adds –fwarn-redundant-constraints (on by
> default). It tells you when a constraint in a signature is unnecessary, e.g.
>
> f :: Ord a => a -> a -> Bool
>
> f x y = True
>
> I think I have done all the necessary library updates etc, so everything
> should build fine.
>
> Four libraries which we don’t maintain have such warnings (MANY of them in
> transformers) so I’m ccing the maintainers:
I've fixed some of the warnings in transformers, but there are still 14
of them, triggered by Applicative becoming a superclass of Monad. I can't
get rid of those because the package has to build with old GHCs when
bootstrapping the compiler.
On Wed, Jan 07, 2015 at 04:27:21PM +0100, Johan Tibell wrote:
> I had one thought though: consider an abstract data type with functions
> that operates over it. I might want to require e.g Ord in the definition
> of a function so I have freedom to change my implementation later,
> even though the current implementation doesn't need Ord. Think of it
> as separating specification and implementation.
I think some of the changes already made are of this sort, exposing
details of the GHC implementation, e.g. the changes to the public
interface of Array and Ratio. For example, it's probably reasonable
to remove the Ix constraint from Data.Array.bounds, but the portable
reference implementation of Data.Array.elems requires Ix, even though
the GHC implementation doesn't. Similarly a portable implementation of
the Functor instance for Array i requires Ix, but the GHC implementation
doesn't.
More information about the ghc-devs
mailing list