Restore invariant in `Data (Ratio a)` instance
authorHerbert Valerio Riedel <hvr@gnu.org>
Wed, 21 Jan 2015 07:21:36 +0000 (08:21 +0100)
committerHerbert Valerio Riedel <hvr@gnu.org>
Thu, 22 Jan 2015 21:36:24 +0000 (22:36 +0100)
commit3df429e29b6fabda12af71091ba4ad1360f49b44
tree3fece93d426fbcd1d9e778d1f086318654a57839
parente6756640bb410258837d186e8c2e339d6746dc11
Restore invariant in `Data (Ratio a)` instance

(2nd attempt, this time leaving the `Constr` using `":%"`)

The Data instance for `Ratio` just uses the raw `:%` constructor and
doesn't check that the result is reduced to normal form.

The fix is to add back the `Integral` constraint on the Data
instance (which was dropped in c409b6f30373535) and to use `%` rather
than `:%` in the `gfoldl` and `gunfold` implementation.

This restores the invariant and matches the behavior of "virtual
constructors" we've used to patch up such problems elsewhere.

This addresses #10011

Reviewed By: ekmett, austin

Differential Revision: https://phabricator.haskell.org/D625
libraries/base/Data/Data.hs
libraries/base/changelog.md