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
61
62
63
64
65
66
67
68
|
structure MLton =
struct
open MLton
structure Platform =
struct
fun peek (l, f) = List.find f l
fun omap (opt, f) = Option.map f opt
val toLower = String.translate (str o Char.toLower)
structure Arch =
struct
datatype t = Alpha | AMD64 | ARM | HPPA | IA64 | m68k |
MIPS | PowerPC | S390 | Sparc | X86
val all = [(Alpha, "Alpha"),
(AMD64, "AMD64"),
(ARM, "ARM"),
(HPPA, "HPPA"),
(IA64, "IA64"),
(m68k, "m68k"),
(MIPS, "MIPS"),
(PowerPC, "PowerPC"),
(S390, "S390"),
(Sparc, "Sparc"),
(X86, "X86")]
fun fromString s =
let
val s = toLower s
in
omap (peek (all, fn (_, s') => s = toLower s'), #1)
end
val host = X86
fun toString a = #2 (valOf (peek (all, fn (a', _) => a = a')))
end
structure OS =
struct
datatype t = AIX | Cygwin | Darwin | FreeBSD | HPUX | Linux
| MinGW | NetBSD | OpenBSD | Solaris
val all = [(AIX, "AIX"),
(Cygwin, "Cygwin"),
(Darwin, "Darwin"),
(FreeBSD, "FreeBSD"),
(HPUX, "HPUX"),
(Linux, "Linux"),
(MinGW, "MinGW"),
(NetBSD, "NetBSD"),
(OpenBSD, "OpenBSD"),
(Solaris, "Solaris")]
fun fromString s =
let
val s = toLower s
in
omap (peek (all, fn (_, s') => s = toLower s'), #1)
end
val host = FreeBSD
fun toString a = #2 (valOf (peek (all, fn (a', _) => a = a')))
end
end
end
|