[GHC] #11995: Can't infer type

GHC ghc-devs at haskell.org
Wed May 25 15:25:46 UTC 2016


#11995: Can't infer type
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.1
  checker)                           |
      Resolution:                    |             Keywords:  TypeInType
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 goldfire):

 This is correct behavior.

 Though I failed to find a mention of the fact in either the user manual or
 in the Haskell 2010 report, a function can use polymorphic recursion only
 when given a type signature. The
 [https://en.wikipedia.org/wiki/Polymorphic_recursion Wikipedia page] on
 polymorphic recursion may be helpful. When you stub out the `xs` with an
 underscore, GHC considers the type signature to be incomplete and it does
 type inference -- not type checking -- on the function. Your function is
 polymorphically recursive, and so this fails.

 Still remaining to do:
  * improve the error message to mutter about polymorphic recursion (not
 sure if this is at all possible)
  * find and/or create documentation to this effect.

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


More information about the ghc-tickets mailing list