
#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