Sat Jan 26 01:42:23 CET 2013

Map and AI

Wait... at the moment that map "consumes" an input variable, it knows
it will be an array.  Why not annotate this information to the
dictionary?  Types can be added in a destructive manner easily.

It really can't be so hard to add a unification-based type inference
to a simple language like this.

The main driver is the desire to infer variable structure, which would
be great.  However, as a side effect, it will probably also solve
float / int distinction.

Seems that this is a good approach:

- map each variable to a type

- every time there is some relation, like : t1 = List t2, perform a

  binding to the type binding table.

- substitute

a : t1
b : t2

c = a + b  => t1 = t2

a : t1
b : t1
c : t1

d = map f c => c,d : t1 = List t3

a : List t3
b : List t3
c : List t3
d : List t3

Basically, this can be done separately, but it would be pretty much
the same derivation as SSA, so might be done together.

It seems there should be no difficulty because there is no inference
step: everything is ordered.

[1] http://en.wikipedia.org/wiki/Hindley%E2%80%93Milner