
#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