File: all-overloads.sml

package info (click to toggle)
mlton 20130715-3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 60,900 kB
  • ctags: 69,386
  • sloc: xml: 34,418; ansic: 17,399; lisp: 2,879; makefile: 1,605; sh: 1,254; pascal: 256; python: 143; asm: 97
file content (60 lines) | stat: -rw-r--r-- 1,794 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
structure List =
   struct
      fun foreach (l, f) = List.app f l
      fun map (l, f) = List.map f l
      val tabulate = List.tabulate
   end

val int =
   List.map (["Int", "IntInf", "LargeInt", "FixedInt", "Position"]
             @ List.map (List.tabulate (31, fn i => i + 2) @ [64],
                         fn i => concat ["Int", Int.toString i]),
             fn s => concat [s, ".int"])

val real =
   List.map (["Real", "Real32", "Real64", "LargeReal"],
             fn s => concat [s, ".real"])

val word =
   List.map (["Word", "LargeWord", "SysWord"]
             @ List.map (List.tabulate (31, fn i => i + 2) @ [64],
                         fn i => concat ["Word", Int.toString i]),
             fn s => concat [s, ".word"])

val text = ["Char.char", "String.string"]

val num = int @ word @ real
val numtext = num @ text
val realint = int @ real
val wordint = int @ word

datatype ty = Binary | Compare | Unary
val binary = Binary
val compare = Compare
val unary = Unary

val () = print "(* This file is automatically generated.  Do not edit. *)\n"
   
val () =
   List.foreach
   ([(2, "~", unary, num),
    (2, "+", binary, num),
    (2, "-", binary, num),
    (2, "*", binary, num),
    (4, "/", binary, real),
    (3, "div", binary, wordint),
    (3, "mod", binary, wordint),
    (3, "abs", unary, realint),
    (1, "<", compare, numtext),
    (1, "<=", compare, numtext),
    (1, ">", compare, numtext),
    (1, ">=", compare, numtext)],
    fn (prec, f, ty, class) =>
    List.foreach
    (class, fn c =>
     print (concat ["fun f (x: ", c, ") = ",
                    case ty of
                      Binary => concat ["x ", f,  " x"]
                    | Compare => concat ["x ", f, " x"]
                    | Unary => concat [f, " x"],
                    "\n"])))