
#8463: Inferred types problem -------------------------------------+------------------------------------ Reporter: danilo2 | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by kosmikus): * status: new => closed * resolution: => invalid Comment: I don't see incorrect behaviour here. Your type annotation is interpreted as being universally quantified: {{{ f x = method1 x :: a -> b -> (a, b) }}} This says that the result of this function is of type `forall a. a -> b -> (a, b)` independently of what the input is, but this isn't true. You need to refer to the type variables introduced by `x`. You can resolve this in various ways: 1. Just use a type signature: {{{ f :: X (a -> b -> (a, b)) -> a -> b -> (a, b) f x = method1 x }}} 2. Enable `ScopedTypeVariables` and annotate the pattern: {{{ f (x :: X (a -> b -> (a, b))) = method1 x :: a -> b -> (a, b) }}} 3. Enable `ScopedTypeVariables` and reuse the type variables from the type signature: {{{ f :: forall a b. X (a -> b -> (a, b)) -> a -> b -> (a, b) f x = method1 x :: a -> b -> (a, b) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8463#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler