[Haskell-cafe] type inference question

minh thu noteed at gmail.com
Thu Oct 8 05:04:35 EDT 2009


Hi,

I'd like to know what are the typing rules used in Haskell (98 is ok).

Specifically, I'd like to know what makes

let i = \x -> x in (i True, i 1)

legal, and not

let a = 1 in (a + (1 :: Int), a + (1.0 :: Float))

Is it correct that polymorphic functions can be used polymorphically
(in multiple places) while non-functions receive a monomorphic type ?

Also, I'd like to know why

id id True

is permitted but not

(\f -> f f True) id

Is it possible to change the later expression so it type checks ? Are
there any type inference algorithms that would accept it ?

I'm asking this because I have implemented a simple type inference
algorithm following PLAI and I can infer the type for id id True
(because I use fresh type variable names for id whenever I apply it
before unification) and have an occur check fail for the later
expression, just like in haskell.

Thanks,
Thu


More information about the Haskell-Cafe mailing list