[plt-scheme] macro question

From: Michael Vanier (mvanier at cs.caltech.edu)
Date: Tue Jun 10 18:56:28 EDT 2008

My experience with ML and Haskell suggests that local type inference is a big win, global type 
inference much less so.  In both Haskell and ML, you usually end up declaring the types of many 
functions somewhere anyway (in module declarations for ML, and in Haskell it's customary to annotate 
all top-level functions with their types).  Not having global types explicitly spelled out often 
leads to very obscure error messages as the inference engine finds the most general type, which is 
often not at all what the programmer had in mind.  So I would like TS to have local type inference 
(to avoid lots of distracting annotations a la Java) but not global type inference.

Parenthetically, both Python and Perl are considering adopting some kind of explicit type 
annotations to the language.  It would be cool for PLT Scheme to do it earlier and better than 
either of them.

Mike


hendrik at topoi.pooq.com wrote:
> On Sun, Jun 08, 2008 at 04:01:02PM -0400, Matthias Felleisen wrote:
> 
>> Pedagogically: Types in TS play the role of contracts in HtDP. All  
>> programs could be assigned types, and the type checker should 'bless'  
>> them all. In the long run, I am considering using Typed Scheme for  
>> the introduction of types into the HtD curriculum. Some unnamed  
>> schools switch to ML for this purpose, but I think type inference  
>> gets in the way of understanding the power of a rich type language.
> 
> Type inference gets in the way of understanding programs in the 
> language.  I need to see the types when I'm reading the program, so I 
> know what it all means.  It's not enough to know that there exists a 
> way of attaching types to the code.
> 
>> (Having said that, TS supports 'local' type inference and we may  
>> develop tools based on past soft typing work (inference via HM or  
>> SBA) to help programmers port untyped modules into the typed world.)
> 
> There are a few type inferences that do not seem to harm the 
> readability of a program.  Type information can flow:
> 
> (a) from the declaration of an identifier to its use
> 
> (b) from the leaves of a parse tree towards its root (the usual 
> direction of expressino evaluation)
> 
> (c) from the root of a parse tree towards the leaves (called coercion in 
> Algol 68; a mechanism whereby the context of an expression affects its 
> meaning.  Used for determining the types of initializers in C.
> 
> I haven't yet seen anything else that didn't become obscure.
> 
> -- hendrik
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.