« Return to Thread: neophyte/clueless type inference question

Re: neophyte/clueless type inference question

by martin odersky-2 :: Rate this Message:

Reply to Author | View in Thread

On 2/10/07, Raoul Duke <raould@...> wrote:
SML-esque languages mostly do not require type annotation for function
signitures. Would that be somthing theoretically do-able in the Scala
framework?

I would be very difficult. The main problem is that the Hindley/Milner-style type inference used in ML and Haskell is really incompatible with subtyping. Theoretically, you can marry the two (see for instance the work on HM(X)), but in practice your types blow up. So Scala uses local type inference instead. Local type inference is flow based; it can infer the type of an anonymous function from its usage, but it cannot infer the type of a method.

Here are two references about local type inference. The second one is closest to what is done in the Scala type system.

http://citeseer.ist.psu.edu/pierce98local.html
http://citeseer.ist.psu.edu/odersky01colored.html

And here's the reference for HM(X):

http://citeseer.ist.psu.edu/16814.html

Cheers

 -- Martin


 « Return to Thread: neophyte/clueless type inference question