[GHC] #8119: better type inference for lambdas

#8119: better type inference for lambdas -------------------------------------------+------------------------------- Reporter: dmwit | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.6.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- With the following code in a file: {{{ {-# LANGUAGE TypeFamilies #-} class Test a where test :: a instance (a ~ Int, b ~ Int) => Test (a -> b) where test = id }}} We can tell ghci that {{{test}}} is a function (and nothing more) in two different ways: {{{ *Main> :t test `asTypeOf` (undefined :: a -> b) test `asTypeOf` (undefined :: a -> b) :: Int -> Int *Main> :t \x -> test x \x -> test x :: Test (t1 -> t) => t1 -> t }}} The type inferred for {{{\x -> test x}}} is very disappointing in comparison! A similar example can be cooked up with MPTCs and functional dependencies; see also http://lpaste.net/91534 for some (still quite abstract, of course) motivation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8119 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8119: better type inference for lambdas
--------------------------------------------+------------------------------
Reporter: dmwit | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (Type checker) | Version: 7.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Test Case: | Difficulty: Unknown
Blocking: | Blocked By:
| Related Tickets:
--------------------------------------------+------------------------------
Comment (by Krzysztof Gogolewski

#8119: better type inference for lambdas
--------------------------------------------+------------------------------
Reporter: dmwit | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (Type checker) | Version: 7.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Test Case: | Difficulty: Unknown
Blocking: | Blocked By:
| Related Tickets:
--------------------------------------------+------------------------------
Comment (by Krzysztof Gogolewski

#8119: better type inference for lambdas -----------------------------------------------+--------------------------- Reporter: dmwit | Owner: Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: typecheck/should_run/T8119 | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: -----------------------------------------------+--------------------------- Changes (by monoidal): * status: new => closed * testcase: => typecheck/should_run/T8119 * resolution: => fixed Comment: It's good in HEAD, which gives `Int -> Int` in both cases. I can't point which commit did it, but I added a regression test. As a clumsy workaround, you can write `let y = \x -> test x; :t y` in 7.6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8119#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC