Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / SMLofNJStructure.adoc
CommitLineData
7f918cf1
CE
1SMLofNJStructure
2================
3
4[source,sml]
5----
6signature SML_OF_NJ =
7 sig
8 structure Cont:
9 sig
10 type 'a cont
11 val callcc: ('a cont -> 'a) -> 'a
12 val isolate: ('a -> unit) -> 'a cont
13 val throw: 'a cont -> 'a -> 'b
14 end
15 structure SysInfo:
16 sig
17 exception UNKNOWN
18 datatype os_kind = BEOS | MACOS | OS2 | UNIX | WIN32
19
20 val getHostArch: unit -> string
21 val getOSKind: unit -> os_kind
22 val getOSName: unit -> string
23 end
24
25 val exnHistory: exn -> string list
26 val exportFn: string * (string * string list -> OS.Process.status) -> unit
27 val exportML: string -> bool
28 val getAllArgs: unit -> string list
29 val getArgs: unit -> string list
30 val getCmdName: unit -> string
31 end
32----
33
34`SMLofNJ` implements a subset of the structure of the same name
35provided in <:SMLNJ:Standard ML of New Jersey>. It is included to
36make it easier to port programs between the two systems. The
37semantics of these functions may be different than in SML/NJ.
38
39* `structure Cont`
40+
41implements continuations.
42
43* `SysInfo.getHostArch ()`
44+
45returns the string for the architecture.
46
47* `SysInfo.getOSKind`
48+
49returns the OS kind.
50
51* `SysInfo.getOSName ()`
52+
53returns the string for the host.
54
55* `exnHistory`
56+
57the same as `MLton.Exn.history`.
58
59* `getCmdName ()`
60+
61the same as `CommandLine.name ()`.
62
63* `getArgs ()`
64+
65the same as `CommandLine.arguments ()`.
66
67* `getAllArgs ()`
68+
69the same as `getCmdName()::getArgs()`.
70
71* `exportFn f`
72+
73saves the state of the computation to a file that will apply `f` to
74the command-line arguments upon restart.
75
76* `exportML f`
77+
78saves the state of the computation to file `f` and continue. Returns
79`true` in the restarted computation and `false` in the continuing
80computation.