Restore invariant in `Data (Ratio a)` instance
ClosedPublic

Authored by hvr on Jan 21 2015, 1:26 AM.

Details

Summary

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 Trac #10011

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
hvr updated this revision to Diff 2149.Jan 21 2015, 1:26 AM
hvr retitled this revision from to Restore invariant in `Data (Ratio a)` instance.
hvr updated this object.
hvr edited the test plan for this revision. (Show Details)
hvr added a reviewer: ekmett.
hvr updated the Trac tickets for this revision.
hvr added a comment.Jan 21 2015, 1:31 AM

(note to myself: add changelog.md entry before landing)

austin accepted this revision.Jan 21 2015, 2:15 AM
austin edited edge metadata.

sealofapproval

This revision is now accepted and ready to land.Jan 21 2015, 2:15 AM
hvr planned changes to this revision.Jan 21 2015, 7:22 AM

@ekmett pointed out something that needs changing

hvr updated this revision to Diff 2150.Jan 21 2015, 7:50 AM
hvr edited edge metadata.

add changelog-entry and use combinator in Data instance

This revision is now accepted and ready to land.Jan 21 2015, 7:50 AM
ekmett accepted this revision.Jan 21 2015, 12:00 PM
ekmett edited edge metadata.

LGTM!

This revision was automatically updated to reflect the committed changes.