Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / SMLofNJStructure.adoc
1 SMLofNJStructure
2 ================
3
4 [source,sml]
5 ----
6 signature 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
35 provided in <:SMLNJ:Standard ML of New Jersey>. It is included to
36 make it easier to port programs between the two systems. The
37 semantics of these functions may be different than in SML/NJ.
38
39 * `structure Cont`
40 +
41 implements continuations.
42
43 * `SysInfo.getHostArch ()`
44 +
45 returns the string for the architecture.
46
47 * `SysInfo.getOSKind`
48 +
49 returns the OS kind.
50
51 * `SysInfo.getOSName ()`
52 +
53 returns the string for the host.
54
55 * `exnHistory`
56 +
57 the same as `MLton.Exn.history`.
58
59 * `getCmdName ()`
60 +
61 the same as `CommandLine.name ()`.
62
63 * `getArgs ()`
64 +
65 the same as `CommandLine.arguments ()`.
66
67 * `getAllArgs ()`
68 +
69 the same as `getCmdName()::getArgs()`.
70
71 * `exportFn f`
72 +
73 saves the state of the computation to a file that will apply `f` to
74 the command-line arguments upon restart.
75
76 * `exportML f`
77 +
78 saves the state of the computation to file `f` and continue. Returns
79 `true` in the restarted computation and `false` in the continuing
80 computation.