[GHC] #8463: Inferred types problem

GHC ghc-devs at haskell.org
Sun Oct 20 14:03:59 UTC 2013


#8463: Inferred types problem
------------------------------------+-------------------------------------
       Reporter:  danilo2           |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  Compiler          |           Version:  7.6.3
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 I've talked about this issue on Haskell irc and nobody knows why types are
 not automatically inferred in this example.

 Lets consider following code:
 {{{
 data X a = X { method1 :: a } deriving(Show)

 cons_X = X { method1 = (\a b -> (a,b)) }

 f x = method1 x :: a -> b -> (a, b)

 main = do
         let x = cons_X
         let a = f x
         return ()
 }}}

 It works if we do not write the explicit type signature. What is
 interesting, If we write it wrong, like

 {{{
 f x = method1 x :: Int
 }}}

 compiler tells us:
 {{{
 Couldn't match type `t0 -> t1 -> (t0, t1)' with `Int'
 }}}

 It does not work if we even specify explicit f type:
 {{{
 f :: X (a -> b -> (a, b)) -> (a -> b -> (a, b))
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8463>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list