September 22, 1999 Strong Typing Slide #18

Type Elaboration Example 2

        fun sumof []     = 0
          | sumof (h::t) = h + sumof t;

Compiler says to itself:

Then it prints:

        val sumof = fn : int list -> int

If we had written 0.0 instead of 0, the compiler would have deduced real list -> real.

If we had written true instead of 0, the compiler would have reported a type error.


Next Copyright © 1999 M-J. Dominus