
#14426: Inferred type not principle/most general? -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => invalid Comment: This is expected behavior. The issue is that the `Fn` constructor uses polymorphic recursion, and type inference in the presence of polymorphic recursion is known to be undecidable. You managed to get lucky and have GHC infer any type at all for `(#)`, but often type inference will fail completely in the presence of polymorphic recursion, as in the example below: {{{#!hs data FullTree a = Leaf | Bin a (FullTree (a, a)) -- size :: FullTree a -> Int size Leaf = 0 size (Bin _ t) = 1 + 2 * size t }}} See the [https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-810004.... Haskell Report's section on type signatures] for more. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14426#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler