Internally defined functions

Comparison functions: these evaluate their arguments only to the extent necessary to determine their order. In comparing distinct constants and constructors, the lesser is the one which came earlier in the data definition in which both were defined. Pairs compare lexicographically, while comparison of functions triggers a run-time error. On the types num, char and list(char), these rules give the normal orderings.

    infix =, /= : 3;
    infix <, =<, >, >= : 4;
    dec =, /=, <, =<, >, >= : alpha # alpha -> bool;
Lower-level comparison functions.
    data relation == LESS ++ EQUAL ++ GREATER;

    dec compare : alpha # alpha -> relation;

    --- x =  y <= (\ EQUAL => true | _ => false) (compare(x, y));
    --- x /= y <= (\ EQUAL => false | _ => true) (compare(x, y));
    --- x <  y <= (\ LESS => true | _ => false) (compare(x, y));
    --- x >= y <= (\ LESS => false | _ => true) (compare(x, y));
    --- x >  y <= (\ GREATER => true | _ => false) (compare(x, y));
    --- x =< y <= (\ GREATER => false | _ => true) (compare(x, y));
Conversions.
    dec ord : char -> num;
    dec chr : num -> char;

    dec num2str : num -> list char;
    dec str2num : list char -> num;
The contents of a named file (created lazily).
    dec read : list char -> list char;
Abort execution with an error message.
    dec error : list char -> alpha;
The usual arithmetical functions.
    infix +, - : 5;
    infix *, /, div, mod : 6;
    dec +, -, *, /, div, mod : num # num -> num;
Math library.
    dec cos, sin, tan, acos, asin, atan : num -> num;
    dec atan2, hypot : num # num -> num;
    dec cosh, sinh, tanh, acosh, asinh, atanh : num -> num;
    dec abs, ceil, floor : num -> num;
    dec exp, log, log10, sqrt : num -> num;
    dec pow : num # num -> num;
    dec erf, erfc : num -> num;
Any extra arguments on the interpreter command line.
    dec argv : list(list char);
Part of the special treatment of the succ constructor.
    dec succ : num -> num;
    --- succ n <= n+1;



Ross Paterson <ross@soi.city.ac.uk>