Remove redundant constraints from libraries, discovered by -fwarn-redundant…

Authored by simonpj.


Remove redundant constraints from libraries, discovered by -fwarn-redundant-constraints

This patch affects libraries, and requires a submodule update.

Some other libraries, maintained by others, have redundant constraints,


I have suppressed the redundant-constraint warnings by settings in

(in this commit)


Group Auditors
Restricted Owners Package
simonpjJan 6 2015, 8:25 AM
rGHC39337a6d97c8: Remove redundant constraints in the compiler itself, found by -fwarn-redundant…
Build Status
Buildable 2852
Build 2865: GHC Continuous Integration (amd64/Linux)
ekmett raised a concern with this commit.Jan 7 2015, 10:45 AM
ekmett added a subscriber: ekmett.

I annotated a few issues with the Data instance for Ratio.


We actually do need this constraint, the code on the left is currently broken:

instance (Data a, Integral a) => Data (Ratio a) where

This needs to use

gfoldl k z (a :% b) = z (%) `k` a `k` b

which uses the Integral constraint.

The fact that this constraint was redundant was actually a bug, we'd fixed an analogous bug in the Storable instance, but apparently missed this one.

The reason we need to use (%) rather than (:%) during construction is that otherwise the Data instance can violate the assumptions of reduction used throughout the rest of the module.

gunfold k z c | constrIndex c == 1 = k (k (z (%)))

I think you are saying that you'd like to change some library code in Data.hs. And when you do, the Integral constraint will be needed again.

If so, please go ahead. You are the Core Libraries committee! I was just removing a constraint that isn't used. If you change the code then of course it'll be used again.


austin added a subscriber: austin.Jan 20 2015, 4:22 PM

@ekmett Any update on this?

ekmett added a subscriber: hvr.Jan 20 2015, 5:52 PM

@austin, I'll throw together an issue in the trac and work with @hvr to get a patch ready.

@ekmett Can you 'accept' this now?

ekmett accepted this commit.Feb 23 2015, 11:00 AM

Now that Herbert has fixed the Data instance for Ratio?

Definitely, as long as this doesn't revert that.