[Haskell-cafe] Limits of deduction
Roberto Zunino
zunino at di.unipi.it
Mon May 14 10:51:26 EDT 2007
Matthew Brecknell wrote:
> Roberto Zunino:
>
>>Here passing both 3 and (\z->z) as y confuses the type inference.
>
> So the type inference is not really confused at all. It just gives a
> not-very-useful type.
Yes, you are right, I didn't want to involve type classes and assumed
3::Int. A better example would be:
polyf :: Int -> a -> Int
polyf x y = if x==0 then 0
else if x==1 then polyf (x-1) (\z->z)
else polyf (x-2) ()
Here, passing both () and (\z->z) _does_ make inference fail.
Zun.
More information about the Haskell-Cafe
mailing list