
#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 nomeata): Using just `TyCon.checkRecTc` is too permissive for `Coercible`. `checkRecTc` succeeds for `Fix (Either x)` (where `newtype Fix f = MkFix (f (Fix f))`) for all type `x`. But then we’d generate the instances {{{ instance Coercible (Either x (Fix (Either x))) b => Coercible (Fix (Either x)) b instance Coercible a (Either x (Fix (Either x))) => Coercible a (Fix (Either x)) }}} so trying to solve the constraint `Coercible (Fix (Either Age)) (Fix (Either Int))` will loop. (With the current implementation, which hooks into the general constraint resolving, I’d expect it to not loop at compile time, but create a diverging witness, and crash at run time. Neither of these are desired). Now what about your example, `newtype RecNT = MkRecNT (Either RecNT String)`. Assume that `Coercible` would work for it, and assume there is also `newtype RecNT2 = MkRecNT2 (Either RecNT2 String)`. Then, similarly, solving `Coercible RecNT RecNT2` will loop with the current implementation... So it is not a matter of relaxing the checks; if we want to support recursive newtypes in `Coercible`, the algorithm needs to be generally overhauled. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8503#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler