[GHC] #10085: Type families cause wrapper types to disappear without cause

#10085: Type families cause wrapper types to disappear without cause -------------------------------------+------------------------------------- Reporter: tathougies | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (Type checker) | Operating System: Unknown/Multiple Keywords: | Type of failure: GHC rejects Architecture: | valid program Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- I tried to summarize the bug in the title, but I'm absolutely at a loss to understand what's going on here. Here's the output of a GHCi session: {{{#!hs GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> :set -XTypeFamilies Prelude> type family Strange (f :: * -> *) ty where { Strange f ty = Maybe (f ty) } Prelude> newtype Identity a = Identity { runIdentity :: a } Prelude> newtype StrangeHolder f = StrangeHolder (f Int) Prelude> let x = Just (Identity 3) :: Strange Identity Int Prelude> :type x x :: Maybe (Identity Int) Prelude> StrangeHolder _ :: StrangeHolder (Strange Identity) <interactive>:8:15: Found hole ‘_’ with type: Maybe (Identity Int) Relevant bindings include it :: StrangeHolder (Strange Identity) (bound at <interactive>:8:1) In the first argument of ‘StrangeHolder’, namely ‘_’ In the expression: StrangeHolder _ :: StrangeHolder (Strange Identity) In an equation for ‘it’: it = StrangeHolder _ :: StrangeHolder (Strange Identity) Prelude> :type x x :: Maybe (Identity Int) Prelude> StrangeHolder x :: StrangeHolder (Strange Identity) <interactive>:10:15: Couldn't match type ‘Identity Int’ with ‘Int’ Expected type: Maybe Int Actual type: Maybe (Identity Int) In the first argument of ‘StrangeHolder’, namely ‘x’ In the expression: StrangeHolder x :: StrangeHolder (Strange Identity) }}} GHC reports that it is expecting the type `Maybe (Identity Int)` as the first argument to `StrangeHolder`. It also reports that `x` has type `Maybe (Identity Int)`, but when I go to put `x` into a `StrangeHolder`, GHC has seemingly gotten rid of Identity, and now expects `x` to be of type `Maybe Int`. I think this is a bug, since the `Identity` type seems to disappear without cause. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10085 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10085: Type families cause wrapper types to disappear without cause -------------------------------------+------------------------------------- Reporter: tathougies | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Comment (by glguy): There may be other issues here, but a significant one is that you're partially applying a type synonym family. This check was missing in 7.8 but is fixed for 7.10 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10085#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10085: Type families cause wrapper types to disappear without cause -------------------------------------+------------------------------------- Reporter: tathougies | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Keywords: Resolution: invalid | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: Yes, glguy is spot on: you cannot partially apply a type family. This was a bug in 7.8 and I have no idea what unpredictable consequences might occur if you do. If you can make your strange behaviour happen with 7.10 then let's look at it. I'm sorry about the bug in 7.8 which has wasted some of your time. I'll close this as invalid (our fault not yours), but do re-open if you can make something like this happen without partial application. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10085#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC