• Herbert Valerio Riedel's avatar
    Restore invariant in `Data (Ratio a)` instance · 3df429e2
    Herbert Valerio Riedel authored
    (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 c409b6f3) 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
    3df429e2
Data.hs 45.9 KB