Monday, August 05, 2013

[wpjnajrx] Type inference with unknown number of parameters

Consider a concise programming language which not only permits omitting type signatures of functions but also omitting the parameters.  The parameters pop into existence when referred to by number within the body of the function, vaguely similar to Perl's @_ array within a sub.  (But we do not permit indexing into the list of parameters by a value not known at compile time.)

How difficult is Hindley-Milner type inference in this situation?  Probably not much more difficult than the ordinary: simply find the largest parameter referred in the body (say 3), and start inference from a1 -> a2 -> a3 -> a4, with a4 potentially a function type.

1 comment :

Anonymous said...

How would you distinguish id and const?