[commit: ghc] ghc-7.10: Restore invariant in `Data (Ratio a)` instance (bcfe534)

git at git.haskell.org git at git.haskell.org
Thu Jan 22 21:59:49 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/bcfe5344a279377d75cdd31a35a1d47c5d4eb1a5/ghc

>---------------------------------------------------------------

commit bcfe5344a279377d75cdd31a35a1d47c5d4eb1a5
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Wed Jan 21 08:21:36 2015 +0100

    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
    
    (cherry picked from commit 3df429e29b6fabda12af71091ba4ad1360f49b44)


>---------------------------------------------------------------

bcfe5344a279377d75cdd31a35a1d47c5d4eb1a5
 libraries/base/Data/Data.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libraries/base/Data/Data.hs b/libraries/base/Data/Data.hs
index 2ca3a0c..fbad1d1 100644
--- a/libraries/base/Data/Data.hs
+++ b/libraries/base/Data/Data.hs
@@ -1059,7 +1059,7 @@ instance Data Word64 where
 ------------------------------------------------------------------------------
 
 ratioConstr :: Constr
-ratioConstr = mkConstr ratioDataType "%" [] Infix
+ratioConstr = mkConstr ratioDataType ":%" [] Infix
 
 ratioDataType :: DataType
 ratioDataType = mkDataType "GHC.Real.Ratio" [ratioConstr]



More information about the ghc-commits mailing list