better type inference for lambdas
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.
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.3 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |