Standard ML of New Jersey (32-bit) v110.99 [built: Thu Dec 24 11:01:10 2020] - fun f1 x = 1 + hd x; val f1 = fn : int list -> int - - fun f1 (x :: _) = 1 + x; stdIn:3.5-3.25 Warning: match nonexhaustive x :: _ => ... val f1 = fn : int list -> int - - f1 []; uncaught exception Match [nonexhaustive match failure] raised at: stdIn:3.25 - - fun f1 x = 1 + hd x; val f1 = fn : int list -> int - f1 []; uncaught exception Empty raised at: smlnj/init/pervasive.sml:193.19-193.24 - - - fun f2 x = hd x + hd (tl x); val f2 = fn : int list -> int - - f2 [2]; uncaught exception Empty raised at: smlnj/init/pervasive.sml:193.19-193.24 - f2 []; uncaught exception Empty raised at: smlnj/init/pervasive.sml:193.19-193.24 - f2 [2, 3, 4]; val it = 5 : int - - - hd []; stdIn:14.1-14.6 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) uncaught exception Empty raised at: smlnj/init/pervasive.sml:193.19-193.24 - - tl []; stdIn:1.2-9.4 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) uncaught exception Empty raised at: smlnj/init/pervasive.sml:195.19-195.24 - - - fun f2 [] = 0 = | f2 [x] = x = | f2 [x, y] = x + y; stdIn:19.5-21.22 Warning: match nonexhaustive nil => ... x :: nil => ... x :: y :: nil => ... val f2 = fn : int list -> int - f2 [2, 3]; val it = 5 : int - f2 [2, 3, 4]; uncaught exception Match [nonexhaustive match failure] raised at: stdIn:21.22 - - - fun f2 [] = 0 = | f2 [x] = x = | f2 [x, y] = x + y = | f2 (x :: y :: _) = x + y; val f2 = fn : int list -> int - f2 [3, 4]; val it = 7 : int - f2 [3, 4, 5]; val it = 7 : int - - - fun f3 x = ((#2 x), (#1 x)); stdIn:42.1-42.28 Error: unresolved flex record (need to know the names of ALL the fields in this context) type: {1:'Y, 2:'X; 'Z} - - - - fun f3 (x:int*int) = ((#2 x), (#1 x)); val f3 = fn : int * int -> int * int - - fun f3 (x:int*int*int) = ((#2 x), (#1 x)); val f3 = fn : int * int * int -> int * int - - fun f3 (x:int*real*char) = ((#2 x), (#1 x)); val f3 = fn : int * real * char -> real * int - - - fun f3 (a, b) = (b, a); val f3 = fn : 'a * 'b -> 'b * 'a - - - fun f3 (a:int, b:int) = (b, a); val f3 = fn : int * int -> int * int - - - - fun f3 (a:int, b:char, c:real) = (b, a); val f3 = fn : int * char * real -> char * int - - - - fun f3 (a, b, c):char*int = (b, a); val f3 = fn : int * char * 'a -> char * int - - - fun f4 x = hd (tl x) :: hd x :: tl (tl x); val f4 = fn : 'a list -> 'a list - - f4 [1]; uncaught exception Empty raised at: smlnj/init/pervasive.sml:193.19-193.24 - - fun f4 (x :: y :: ys) = y :: x :: ys; stdIn:74.5-74.37 Warning: match nonexhaustive x :: y :: ys => ... val f4 = fn : 'a list -> 'a list - - f4 [1]; uncaught exception Match [nonexhaustive match failure] raised at: stdIn:74.37 - f4 []; stdIn:1.2-74.4 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) uncaught exception Match [nonexhaustive match failure] raised at: stdIn:74.37 - - fun f4 [] = [] = | f4 [x] = [x] = | f4 (x :: y :: ys) = y :: x :: ys; val f4 = fn : 'a list -> 'a list - - f4 []; stdIn:80.1-80.6 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) val it = [] : ?.X1 list - - f4 []:int list; val it = [] : int list - - f4 []:real list; val it = [] : real list - - f4 []:char list; val it = [] : char list - - f4 []; stdIn:88.1-88.6 Warning: type vars not generalized because of value restriction are instantiated to dummy types (X1,X2,...) val it = [] : ?.X1 list - - - - fun f5 x = (hd (tl x) + hd x) :: tl (tl x); val f5 = fn : int list -> int list - - f5 [1,2,3,4]; val it = [3,3,4] : int list - - f5 [5,3,4]; val it = [8,4] : int list - - - fun f5 (x :: y :: ys) = (x + y) :: ys; stdIn:102.5-102.38 Warning: match nonexhaustive x :: y :: ys => ... val f5 = fn : int list -> int list - - - - fun f5 [] = [] = | f5 [x] = [x] = | f5 (x :: y :: ys) = (x + y) :: ys; val f5 = fn : int list -> int list - - - - fun f2 x :int = 1 + x; val f2 = fn : int -> int - - - fun f2 x:real = 1.0 + real x; val f2 = fn : int -> real - fun f2 (x:int):real = 1.0 + real x; val f2 = fn : int -> real - fun f2 x:real = 1.0 + real x; val f2 = fn : int -> real - - fun h1 x y = real (round x + y); val h1 = fn : real -> int -> real - fun h2 (x:real) (y:int):real = real (round x + y); val h2 = fn : real -> int -> real - - h1; val it = fn : real -> int -> real - h2; val it = fn : real -> int -> real - - - - fun k1 x y = x ^ Int.toString y; [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable] [autoloading done] val k1 = fn : string -> int -> string - - fun k1 x y = x ^ Int.toString y; val k1 = fn : string -> int -> string - fun k2 (x:string) (y:int):string = x ^ Int.toString y; val k2 = fn : string -> int -> string - - - k1; val it = fn : string -> int -> string - k2; val it = fn : string -> int -> string - - - fun p1 x y = (x+y, real(x*y)); val p1 = fn : int -> int -> int * real - fun p2 (x:int) (y:int):int*real = (x+y, real(x*y)); val p2 = fn : int -> int -> int * real - - p1; val it = fn : int -> int -> int * real - p2; val it = fn : int -> int -> int * real - - - fun s1 x y = (round (hd x), y); val s1 = fn : real list -> 'a -> int * 'a -