[gdome@tempest ~] sml Standard ML of New Jersey v110.78 [built: Wed Jan 14 12:52:09 2015] - 1 + 2; val it = 3 : int - 1 + 2 = +3; val it = 6 : int - 3 + 4 = ; val it = 7 : int - 3+4; val it = 7 : int - 7 = + = 8 = ; val it = 15 : int - 3+4*5; val it = 23 : int - val a = 2+3; val a = 5 : int - a*a; val it = 25 : int - a = 5; val it = true : bool - it; val it = true : bool - a+10; val it = 15 : int - it*10; val it = 150 : int - 2-5; val it = ~3 : int - ~3 = ; val it = ~3 : int - -3; stdIn:21.1 Error: expression or pattern begins with infix identifier "-" stdIn:21.1-21.3 Error: operator and operand don't agree [overload conflict] operator domain: [- ty] * [- ty] operand: [int ty] in expression: - 3 - ~(2+3); val it = ~5 : int - 7/2; stdIn:22.1-22.4 Error: operator and operand don't agree [overload conflict] operator domain: real * real operand: [int ty] * [int ty] in expression: 7 / 2 - 7.0/2.0; val it = 3.5 : real - 7.0/2; stdIn:23.1-23.6 Error: operator and operand don't agree [overload conflict] operator domain: real * real operand: real * [int ty] in expression: 7.0 / 2 - 7 div 2; val it = 3 : int - 7 mod 3; val it = 1 : int - 7 rem 3; stdIn:25.3-25.6 Error: unbound variable or constructor: rem stdIn:25.1-25.8 Error: operator is not a function [overload conflict] operator: [int ty] in expression: 7 (* This is a comment. (* And comments nest properly. *) Yay! *) (* How to know what operators/functions are available in the "top-level" interpreter? Look at http://sml-family.org/Basis/top-level-chapter.html *) - val inc = fn x => x+1; val inc = fn : int -> int - val incReal = fn x => x+1.0; val incReal = fn : real -> real - inc 10; val it = 11 : int - inc 5.0 = ; stdIn:28.1-28.8 Error: operator and operand don't agree [tycon mismatch] operator domain: int operand: real in expression: inc 5.0 - val dbl = fn y => y*2; val dbl = fn : int -> int - dbl 10; val it = 20 : int - fun sub5 z = z - 5; val sub5 = fn : int -> int - sub5 17; val it = 12 : int - sub5; val it = fn : int -> int - (fn a => a*3) 10; val it = 30 : int - val weird = fn x => (x+2)*(x+3.0); stdIn:35.28-35.33 Error: operator and operand don't agree [overload conflict] operator domain: [+ ty] * [+ ty] operand: [+ ty] * real in expression: x + 3.0 - Real.fromInt(2); [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [autoloading done] val it = 2.0 : real - val weird = fn x => (Real.fromInt(x+2))*(Real.fromInt(x)+3.0); val weird = fn : int -> real - dbl 5; val it = 10 : int - dbl(5); val it = 10 : int - dbl((5)); val it = 10 : int - (dbl 5) = ; val it = 10 : int - inc (dbl 5); val it = 11 : int - (inc dbl) 5; stdIn:43.2-43.9 Error: operator and operand don't agree [tycon mismatch] operator domain: int operand: int -> int in expression: inc dbl - inc dbl 5; stdIn:1.2-24.1 Error: operator and operand don't agree [tycon mismatch] operator domain: int operand: int -> int in expression: inc dbl