Restore invariant in `Data (Ratio a)` instance

Authored by hvr.


Restore invariant in Data (Ratio a) instance

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

Reviewed By: ekmett, austin

Differential Revision:


Group Auditors
Restricted Owners Package
hvrJan 21 2015, 12:31 PM
Differential Revision
D625: Restore invariant in `Data (Ratio a)` instance
rGHCca15376d9371: Update Backpack document with examples [skip ci]
Reverted By
rGHC22c4d60b0665: Revert "Restore invariant in `Data (Ratio a)` instance"
Build Status
Buildable 2995
Build 3021: GHC Continuous Integration (amd64/Linux)
nomeata raised a concern with this commit.Jan 21 2015, 2:07 PM
nomeata added a subscriber: nomeata.

I get this on traivs:

Compile failed (status 256) errors were:
[1 of 2] Compiling A                ( A.hs, A.o )
[2 of 2] Compiling Main             ( T4491.hs, T4491.o )

    Illegal data constructor name: ‘%’
    When splicing a TH expression: (GHC.Real.%) 11 2
    In the splice: $(dataToExpQ (const Nothing) (5.5 :: Rational))

*** unexpected failure for T4491(normal)
hvr added a comment.EditedJan 21 2015, 3:12 PM

damn... @austin why didn't Harbormaster tell me in D625 about that?

hvr added a subscriber: austin.Jan 21 2015, 3:12 PM
austin added a comment.EditedJan 23 2015, 7:44 AM

No clue I'm afraid. What do the build logs for that revision on Harbormaster say?

hvr added a comment.Jan 23 2015, 8:15 AM

well, that's the thing... there wasn't any buildjob triggered...

I now see that. Unfortunately I couldn't tell you why still; we can run builds manually in these cases though...

@hvr Can we accept this now to get it out of our way?

hvr accepted this commit.Feb 23 2015, 8:51 AM

sure :)

austin accepted this commit.Mar 3 2015, 4:52 AM