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

Authored by simonpj.

Description

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,
namely:

containers
haskeline
transformers
binary

I have suppressed the redundant-constraint warnings by settings in

validate-settings.mk

(in this commit)

Details

Group Auditors
Restricted Owners Package
Committed
simonpjJan 6 2015, 8:25 AM
Parents
rGHC39337a6d97c8: Remove redundant constraints in the compiler itself, found by -fwarn-redundant…
Branches
Unknown
Tags
Unknown
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.

/libraries/base/Data/Data.hs
1067

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

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

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.

1070
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.

Simon

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.