#2782: Data instance for ratio changed, now incompatible
---------------------------------+------------------------------------------
    Reporter:  NeilMitchell      |        Owner:                  
        Type:  bug               |       Status:  new             
    Priority:  normal            |    Milestone:                  
   Component:  Compiler          |      Version:  6.10.1          
    Severity:  normal            |   Resolution:                  
    Keywords:                    |     Testcase:                  
Architecture:  Unknown/Multiple  |           Os:  Unknown/Multiple
---------------------------------+------------------------------------------
Comment (by claus):

 I'm not sure I follow: neither strictness nor `fromConstr` have changed (I
 think?). The only change I'm aware of is that the `Data` instance for
 `Ratio` used to be inconsistent (treating the type as abstract for
 `gfoldl` and as concrete for `gunfold`), while it now treats the type as
 concrete for both directions.

 Your example tries to map a query over the subterms of an undefined
 `Ratio`, relying on the old half-abstract behaviour for not actually
 looking for subterms. Whereas with the new instance `gmapQ` will look for
 subterms and fail. The old behaviour can be restored by making the
 abstract handling of `Ratio` explicit:
 {{{
 ctr2 t = length $ (gmapQ (const undefined) `extQ` ratio) $ asTypeOf
 (fromConstr $ ctr t) t

 test = ctr2 u

 ratio :: Ratio Integer -> [a]
 ratio _ = []
 }}}

 Now we get `0` from both versions of ghc.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2782#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to