neophyte/clueless type inference question

View: New views
3 Messages — Rating Filter:   Alert me  

neophyte/clueless type inference question

by Raoul Duke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

SML-esque languages mostly do not require type annotation for function
signitures. Would that be somthing theoretically do-able in the Scala
framework?

Re: neophyte/clueless type inference question

by martin odersky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



Re: neophyte/clueless type inference question

by Raoul Duke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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.

Ah, got it. (I'm familiar with the terms, but haven't really studied typing.)

> 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

I will have to read those, thanks. If I can understand them I'll be
able to sound a lot less undergraduate on LtU :-)