Let's discuss briefly some general issues concerning Standard ML. First of all, functions are first-class data objects. They can be parsed as arguments, returned as results, stored in variables. Hence, SML supports higher order functions. Here is an example of a higher order function. The MAP function, as you can see, takes as input a function and a list and it produces the list obtained by applying this function to all the elements of the list. The principal control mechanism of SML is in fact a recursive function application. But there are no distracters. Functions can analyse their arguments using pattern matching. SML is an interactive language. Every phrase is read, analysed, compiled and executed. And the value of the phrase is reported together with its type. In fact, SML, as we have mentioned already, is strongly typed, that is every expression has a type, which is inferred automatically by the compiler. No problem can therefore incur a type error at one time. Type-checking is decidable and here I have listed two examples of different kinds of analysis which should suggest what the role of type-checking is as intended in type-functional languages. Look at congruence checks as are taught to children in preparatory classes or dimension analysis in physics. | ![]() |