Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / regression / generate / all-overloads.sml
CommitLineData
7f918cf1
CE
1structure List =
2 struct
3 fun foreach (l, f) = List.app f l
4 fun map (l, f) = List.map f l
5 val tabulate = List.tabulate
6 end
7
8val int =
9 List.map (["Int", "IntInf", "LargeInt", "FixedInt", "Position"]
10 @ List.map (List.tabulate (31, fn i => i + 2) @ [64],
11 fn i => concat ["Int", Int.toString i]),
12 fn s => concat [s, ".int"])
13
14val real =
15 List.map (["Real", "Real32", "Real64", "LargeReal"],
16 fn s => concat [s, ".real"])
17
18val word =
19 List.map (["Word", "LargeWord", "SysWord"]
20 @ List.map (List.tabulate (31, fn i => i + 2) @ [64],
21 fn i => concat ["Word", Int.toString i]),
22 fn s => concat [s, ".word"])
23
24val text = ["Char.char", "String.string"]
25
26val num = int @ word @ real
27val numtext = num @ text
28val realint = int @ real
29val wordint = int @ word
30
31datatype ty = Binary | Compare | Unary
32val binary = Binary
33val compare = Compare
34val unary = Unary
35
36val () = print "(* This file is automatically generated. Do not edit. *)\n"
37
38val () =
39 List.foreach
40 ([(2, "~", unary, num),
41 (2, "+", binary, num),
42 (2, "-", binary, num),
43 (2, "*", binary, num),
44 (4, "/", binary, real),
45 (3, "div", binary, wordint),
46 (3, "mod", binary, wordint),
47 (3, "abs", unary, realint),
48 (1, "<", compare, numtext),
49 (1, "<=", compare, numtext),
50 (1, ">", compare, numtext),
51 (1, ">=", compare, numtext)],
52 fn (prec, f, ty, class) =>
53 List.foreach
54 (class, fn c =>
55 print (concat ["fun f (x: ", c, ") = ",
56 case ty of
57 Binary => concat ["x ", f, " x"]
58 | Compare => concat ["x ", f, " x"]
59 | Unary => concat [f, " x"],
60 "\n"])))