4 The `MLton` structure contains a lot of functionality that is not
5 available in the <:BasisLibrary:Basis Library>. As a warning,
6 please keep in mind that the `MLton` structure and its
7 substructures do change from release to release of MLton.
13 val eq: 'a * 'a -> bool
14 val equal: 'a * 'a -> bool
15 val hash: 'a -> Word32.word
18 val shareAll: unit -> unit
21 structure Array: MLTON_ARRAY
22 structure BinIO: MLTON_BIN_IO
23 structure CharArray: MLTON_MONO_ARRAY where type t = CharArray.array
24 where type elem = CharArray.elem
25 structure CharVector: MLTON_MONO_VECTOR where type t = CharVector.vector
26 where type elem = CharVector.elem
27 structure Cont: MLTON_CONT
28 structure Exn: MLTON_EXN
29 structure Finalizable: MLTON_FINALIZABLE
30 structure GC: MLTON_GC
31 structure IntInf: MLTON_INT_INF
32 structure Itimer: MLTON_ITIMER
33 structure LargeReal: MLTON_REAL where type t = LargeReal.real
34 structure LargeWord: MLTON_WORD where type t = LargeWord.word
35 structure Platform: MLTON_PLATFORM
36 structure Pointer: MLTON_POINTER
37 structure ProcEnv: MLTON_PROC_ENV
38 structure Process: MLTON_PROCESS
39 structure Profile: MLTON_PROFILE
40 structure Random: MLTON_RANDOM
41 structure Real: MLTON_REAL where type t = Real.real
44 val castFromWord: Word32.word -> t
45 val castToWord: t -> Word32.word
46 end where type t = Real32.real
49 val castFromWord: Word64.word -> t
50 val castToWord: t -> Word64.word
51 end where type t = Real64.real
52 structure Rlimit: MLTON_RLIMIT
53 structure Rusage: MLTON_RUSAGE
54 structure Signal: MLTON_SIGNAL
55 structure Syslog: MLTON_SYSLOG
56 structure TextIO: MLTON_TEXT_IO
57 structure Thread: MLTON_THREAD
58 structure Vector: MLTON_VECTOR
59 structure Weak: MLTON_WEAK
60 structure Word: MLTON_WORD where type t = Word.word
61 structure Word8: MLTON_WORD where type t = Word8.word
62 structure Word16: MLTON_WORD where type t = Word16.word
63 structure Word32: MLTON_WORD where type t = Word32.word
64 structure Word64: MLTON_WORD where type t = Word64.word
65 structure Word8Array: MLTON_MONO_ARRAY where type t = Word8Array.array
66 where type elem = Word8Array.elem
67 structure Word8Vector: MLTON_MONO_VECTOR where type t = Word8Vector.vector
68 where type elem = Word8Vector.elem
69 structure World: MLTON_WORLD
80 * <:MLtonFinalizable:>
108 returns true if `x` and `y` are equal as pointers. For simple types
109 like `char`, `int`, and `word`, this is the same as equals. For
110 arrays, datatypes, strings, tuples, and vectors, this is a simple
111 pointer equality. The semantics is a bit murky.
115 returns true if `x` and `y` are structurally equal. For equality
116 types, this is the same as <:PolymorphicEquality:>. For other types,
117 it is a conservative approximation of equivalence.
121 returns a structural hash of `x`. The hash function is consistent
122 between execution of the same program, but may not be consistent
123 between different programs.
127 is always `true` in a MLton implementation, and is always `false` in a
132 maximizes sharing in the heap for the object graph reachable from `x`.
136 maximizes sharing in the heap by sharing space for equivalent
137 immutable objects. A call to `shareAll` performs a major garbage
138 collection, and takes time proportional to the size of the heap.
142 returns the amount of heap space (in bytes) taken by the value of `x`,
143 including all objects reachable from `x` by following pointers. It
144 takes time proportional to the size of `x`. See below for an example.
147 == <!Anchor(size)>Example of `MLton.size` ==
149 This example, `size.sml`, demonstrates the application of `MLton.size`
150 to many different kinds of objects.
153 sys::[./bin/InclGitFile.py mlton master doc/examples/size/size.sml]
156 Compile and run as usual.
160 The size of an int list of length 4 is 48 bytes.
161 The size of a string of length 10 is 24 bytes.
162 The size of an int array of length 10 is 52 bytes.
163 The size of a double array of length 10 is 92 bytes.
164 The size of an array of length 10 of 2-ples of ints is 92 bytes.
165 The size of a useless function is 0 bytes.
166 The size of a continuation option ref is 4544 bytes.
168 The size of a continuation option ref is 8 bytes.
171 Note that sizes are dependent upon the target platform and compiler