[GHC] #10011: The Data instance for Ratio violates internal invariants.

GHC ghc-devs at haskell.org
Wed Jan 21 00:00:03 UTC 2015


#10011: The Data instance for Ratio violates internal invariants.
-------------------------------------+-------------------------------------
        Reporter:  ekmett            |                   Owner:  ekmett
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Core Libraries    |                 Version:  7.10.1-rc1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
Description changed by ekmett:

Old description:

> I found this when Simon was cleaning up unused dependencies in
>
> {{{
> https://phabricator.haskell.org/rGHCc409b6f30373535b6eed92e55d4695688d32be9e#10730
> }}}
>
> The Data instance for Ratio just uses the raw `(:%)` constructor and
> doesn't check that the result is reduced to normal form.
>
> It strikes me that the fix is to add back the Integral constraint on the
> Data instance and to use `(%)` rather than `(:%)` in the `gfoldl` and
> `gunfold` code.
>
> This restores the invariant and matches the behavior of "virtual
> constructors" we've used to patch up such problems  elsewhere.

New description:

 I found this when Simon was cleaning up unused dependencies in

 https://phabricator.haskell.org/rGHCc409b6f30373535b6eed92e55d4695688d32be9e#10730

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

 It strikes me that the fix is to add back the Integral constraint on the
 Data instance and to use `(%)` rather than `(:%)` in the `gfoldl` and
 `gunfold` code.

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

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10011#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list