[GHC] #8503: New GeneralizedNewtypeDeriving check still isn't permissive enough

GHC ghc-devs at haskell.org
Tue Nov 19 09:11:41 UTC 2013


#8503: New GeneralizedNewtypeDeriving check still isn't permissive enough
-------------------------------------+------------------------------------
        Reporter:  goldfire          |            Owner:  goldfire
            Type:  bug               |           Status:  new
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.7
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by simonpj):

 I discussed with Joachim.  The "apartness" idea definitely doesn't work.
 Consider
 {{{
 newtype Fix1 x = F1 (x (Fix1 x))
 newtype Fix2 x = F2 (x (Fix2 x))
 }}}
 and try solving `Coercible (Fix1 (Either Age)) (Fix2 (Either Int))`.
 Everything is fully known, and always apart, yet we get a loop.

 Moreover, analysing the definitions to find loop breakers (as GHC does
 now) fails in the presence of type functions
 {{{
 newtype Bad a = B (F a)
 type instance F Int = Bad Int
 }}}

 Conclusion: the depth-bound idea is the only real option.

 We also need to prevent the construction of recursive dictionaries, but we
 can use the depth of a constraint to stop that too; do not solve a
 constraint of depth n by using a constraint of lower depth.  This is
 rather conservative, but it's enough to prevent recursive dictionary
 construction.

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


More information about the ghc-tickets mailing list