[GHC] #16322: "deriving newtype instance" generates an infinite loop
GHC
ghc-devs at haskell.org
Fri Feb 15 20:40:37 UTC 2019
#16322: "deriving newtype instance" generates an infinite loop
-------------------------------------+-------------------------------------
Reporter: paf31 | Owner: (none)
Type: bug | Status: infoneeded
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by paf31):
I'll break down my understanding step-by-step based on what you've said
above, and please let me know where I go wrong:
1. I require `C (X String a) (X String b)` given `C a b`
2. `deriving newtype` uses the newtype only in the last type argument, so
GHC reduces this to looking for an instance of `C (X String a) b`.
3. The only instances that could ever possibly be applicable (even just
based on the class) are `C Int Int`, `C a b` (in scope locally) and `C (X
String a) (X String b)` itself (the recursive instance which is apparently
chosen) but each leads to a contradiction (note that the functional
dependency means I can infer the first type argument from the second):
- `C Int Int` fails via `Int ~ X String a`.
- `C a b` forces `X String a ~ a`
- `C (X String a) (X String b)` forces `X String b ~ b`.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16322#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list