5 The <:StandardML:Standard ML> Basis Library is a collection of modules
6 dealing with basic types, input/output, OS interfaces, and simple
7 datatypes. It is intended as a portable library usable across all
8 implementations of SML. For the official online version of the Basis
9 Library specification, see http://www.standardml.org/Basis.
10 <!Cite(GansnerReppy04, The Standard ML Basis Library)> is a book
11 version that includes all of the online version and more. For a
12 reverse chronological list of changes to the specification, see
13 http://www.standardml.org/Basis/history.html.
15 MLton implements all of the required portions of the Basis Library.
16 MLton also implements many of the optional structures. You can obtain
17 a complete and current list of what's available using
18 `mlton -show-basis` (see <:ShowBasis:>). By default, MLton makes the
19 Basis Library available to user programs. You can also
20 <:MLBasisAvailableLibraries:access the Basis Library> from
21 <:MLBasis: ML Basis> files.
23 Below is a complete list of what MLton implements.
25 == Top-level types and constructors ==
29 `datatype bool = false | true`
37 ++datatype 'a list = nil | {two-colons} of ('a * 'a list)++
39 `datatype 'a option = NONE | SOME of 'a`
41 `datatype order = EQUAL | GREATER | LESS`
45 `datatype 'a ref = ref of 'a`
57 == Top-level exception constructors ==
83 == Top-level values ==
85 MLton does not implement the optional top-level value
86 `use: string -> unit`, which conflicts with whole-program
87 compilation because it allows new code to be loaded dynamically.
89 MLton implements all other top-level values:
131 == Overloaded identifiers ==
146 == Top-level signatures ==
274 == Top-level structures ==
276 `structure Array: ARRAY`
278 `structure Array2: ARRAY2`
280 `structure ArraySlice: ARRAY_SLICE`
282 `structure BinIO: BIN_IO`
284 `structure BinPrimIO: PRIM_IO`
286 `structure Bool: BOOL`
288 `structure BoolArray: MONO_ARRAY`
290 `structure BoolArray2: MONO_ARRAY2`
292 `structure BoolArraySlice: MONO_ARRAY_SLICE`
294 `structure BoolVector: MONO_VECTOR`
296 `structure BoolVectorSlice: MONO_VECTOR_SLICE`
298 `structure Byte: BYTE`
300 `structure Char: CHAR`
302 * `Char` characters correspond to ISO-8859-1. The `Char` functions do not depend on locale.
304 `structure CharArray: MONO_ARRAY`
306 `structure CharArray2: MONO_ARRAY2`
308 `structure CharArraySlice: MONO_ARRAY_SLICE`
310 `structure CharVector: MONO_VECTOR`
312 `structure CharVectorSlice: MONO_VECTOR_SLICE`
314 `structure CommandLine: COMMAND_LINE`
316 `structure Date: DATE`
318 * `Date.fromString` and `Date.scan` accept a space in addition to a zero for the first character of the day of the month. The Basis Library specification only allows a zero.
320 `structure FixedInt: INTEGER`
322 `structure General: GENERAL`
324 `structure GenericSock: GENERIC_SOCK`
326 `structure IEEEReal: IEEE_REAL`
328 `structure INetSock: INET_SOCK`
332 `structure Int: INTEGER`
334 `structure Int1: INTEGER`
336 `structure Int2: INTEGER`
338 `structure Int3: INTEGER`
340 `structure Int4: INTEGER`
344 `structure Int31: INTEGER`
346 `structure Int32: INTEGER`
348 `structure Int64: INTEGER`
350 `structure IntArray: MONO_ARRAY`
352 `structure IntArray2: MONO_ARRAY2`
354 `structure IntArraySlice: MONO_ARRAY_SLICE`
356 `structure IntVector: MONO_VECTOR`
358 `structure IntVectorSlice: MONO_VECTOR_SLICE`
360 `structure Int8: INTEGER`
362 `structure Int8Array: MONO_ARRAY`
364 `structure Int8Array2: MONO_ARRAY2`
366 `structure Int8ArraySlice: MONO_ARRAY_SLICE`
368 `structure Int8Vector: MONO_VECTOR`
370 `structure Int8VectorSlice: MONO_VECTOR_SLICE`
372 `structure Int16: INTEGER`
374 `structure Int16Array: MONO_ARRAY`
376 `structure Int16Array2: MONO_ARRAY2`
378 `structure Int16ArraySlice: MONO_ARRAY_SLICE`
380 `structure Int16Vector: MONO_VECTOR`
382 `structure Int16VectorSlice: MONO_VECTOR_SLICE`
384 `structure Int32: INTEGER`
386 `structure Int32Array: MONO_ARRAY`
388 `structure Int32Array2: MONO_ARRAY2`
390 `structure Int32ArraySlice: MONO_ARRAY_SLICE`
392 `structure Int32Vector: MONO_VECTOR`
394 `structure Int32VectorSlice: MONO_VECTOR_SLICE`
396 `structure Int64Array: MONO_ARRAY`
398 `structure Int64Array2: MONO_ARRAY2`
400 `structure Int64ArraySlice: MONO_ARRAY_SLICE`
402 `structure Int64Vector: MONO_VECTOR`
404 `structure Int64VectorSlice: MONO_VECTOR_SLICE`
406 `structure IntInf: INT_INF`
408 `structure LargeInt: INTEGER`
410 `structure LargeIntArray: MONO_ARRAY`
412 `structure LargeIntArray2: MONO_ARRAY2`
414 `structure LargeIntArraySlice: MONO_ARRAY_SLICE`
416 `structure LargeIntVector: MONO_VECTOR`
418 `structure LargeIntVectorSlice: MONO_VECTOR_SLICE`
420 `structure LargeReal: REAL`
422 `structure LargeRealArray: MONO_ARRAY`
424 `structure LargeRealArray2: MONO_ARRAY2`
426 `structure LargeRealArraySlice: MONO_ARRAY_SLICE`
428 `structure LargeRealVector: MONO_VECTOR`
430 `structure LargeRealVectorSlice: MONO_VECTOR_SLICE`
432 `structure LargeWord: WORD`
434 `structure LargeWordArray: MONO_ARRAY`
436 `structure LargeWordArray2: MONO_ARRAY2`
438 `structure LargeWordArraySlice: MONO_ARRAY_SLICE`
440 `structure LargeWordVector: MONO_VECTOR`
442 `structure LargeWordVectorSlice: MONO_VECTOR_SLICE`
444 `structure List: LIST`
446 `structure ListPair: LIST_PAIR`
448 `structure Math: MATH`
450 `structure NetHostDB: NET_HOST_DB`
452 `structure NetProtDB: NET_PROT_DB`
454 `structure NetServDB: NET_SERV_DB`
458 `structure Option: OPTION`
460 `structure PackReal32Big: PACK_REAL`
462 `structure PackReal32Little: PACK_REAL`
464 `structure PackReal64Big: PACK_REAL`
466 `structure PackReal64Little: PACK_REAL`
468 `structure PackRealBig: PACK_REAL`
470 `structure PackRealLittle: PACK_REAL`
472 `structure PackWord16Big: PACK_WORD`
474 `structure PackWord16Little: PACK_WORD`
476 `structure PackWord32Big: PACK_WORD`
478 `structure PackWord32Little: PACK_WORD`
480 `structure PackWord64Big: PACK_WORD`
482 `structure PackWord64Little: PACK_WORD`
484 `structure Position: INTEGER`
486 `structure Posix: POSIX`
488 `structure Real: REAL`
490 `structure RealArray: MONO_ARRAY`
492 `structure RealArray2: MONO_ARRAY2`
494 `structure RealArraySlice: MONO_ARRAY_SLICE`
496 `structure RealVector: MONO_VECTOR`
498 `structure RealVectorSlice: MONO_VECTOR_SLICE`
500 `structure Real32: REAL`
502 `structure Real32Array: MONO_ARRAY`
504 `structure Real32Array2: MONO_ARRAY2`
506 `structure Real32ArraySlice: MONO_ARRAY_SLICE`
508 `structure Real32Vector: MONO_VECTOR`
510 `structure Real32VectorSlice: MONO_VECTOR_SLICE`
512 `structure Real64: REAL`
514 `structure Real64Array: MONO_ARRAY`
516 `structure Real64Array2: MONO_ARRAY2`
518 `structure Real64ArraySlice: MONO_ARRAY_SLICE`
520 `structure Real64Vector: MONO_VECTOR`
522 `structure Real64VectorSlice: MONO_VECTOR_SLICE`
524 `structure Socket: SOCKET`
526 * The Basis Library specification requires functions like
527 `Socket.sendVec` to raise an exception if they fail. However, on some
528 platforms, sending to a socket that hasn't yet been connected causes a
529 `SIGPIPE` signal, which invokes the default signal handler for
530 `SIGPIPE` and causes the program to terminate. If you want the
531 exception to be raised, you can ignore `SIGPIPE` by adding the
532 following to your program.
539 setHandler (Posix.Signal.pipe, Handler.ignore)
543 `structure String: STRING`
545 * The `String` functions do not depend on locale.
547 `structure StringCvt: STRING_CVT`
549 `structure Substring: SUBSTRING`
551 `structure SysWord: WORD`
553 `structure Text: TEXT`
555 `structure TextIO: TEXT_IO`
557 `structure TextPrimIO: PRIM_IO`
559 `structure Time: TIME`
561 `structure Timer: TIMER`
563 `structure Unix: UNIX`
565 `structure UnixSock: UNIX_SOCK`
567 `structure Vector: VECTOR`
569 `structure VectorSlice: VECTOR_SLICE`
571 `structure Word: WORD`
573 `structure Word1: WORD`
575 `structure Word2: WORD`
577 `structure Word3: WORD`
579 `structure Word4: WORD`
583 `structure Word31: WORD`
585 `structure Word32: WORD`
587 `structure Word64: WORD`
589 `structure WordArray: MONO_ARRAY`
591 `structure WordArray2: MONO_ARRAY2`
593 `structure WordArraySlice: MONO_ARRAY_SLICE`
595 `structure WordVectorSlice: MONO_VECTOR_SLICE`
597 `structure WordVector: MONO_VECTOR`
599 `structure Word8Array: MONO_ARRAY`
601 `structure Word8Array2: MONO_ARRAY2`
603 `structure Word8ArraySlice: MONO_ARRAY_SLICE`
605 `structure Word8Vector: MONO_VECTOR`
607 `structure Word8VectorSlice: MONO_VECTOR_SLICE`
609 `structure Word16Array: MONO_ARRAY`
611 `structure Word16Array2: MONO_ARRAY2`
613 `structure Word16ArraySlice: MONO_ARRAY_SLICE`
615 `structure Word16Vector: MONO_VECTOR`
617 `structure Word16VectorSlice: MONO_VECTOR_SLICE`
619 `structure Word32Array: MONO_ARRAY`
621 `structure Word32Array2: MONO_ARRAY2`
623 `structure Word32ArraySlice: MONO_ARRAY_SLICE`
625 `structure Word32Vector: MONO_VECTOR`
627 `structure Word32VectorSlice: MONO_VECTOR_SLICE`
629 `structure Word64Array: MONO_ARRAY`
631 `structure Word64Array2: MONO_ARRAY2`
633 `structure Word64ArraySlice: MONO_ARRAY_SLICE`
635 `structure Word64Vector: MONO_VECTOR`
637 `structure Word64VectorSlice: MONO_VECTOR_SLICE`
639 == Top-level functors ==
647 * MLton's `StreamIO` functor takes structures `ArraySlice` and
648 `VectorSlice` in addition to the arguments specified in the Basis
649 Library specification.
651 == Type equivalences ==
653 The following types are equivalent.
656 LargeInt = IntInf.int
657 LargeReal.real = Real64.real
658 LargeWord = Word64.word
661 The default `int`, `real`, and `word` types may be set by the
662 ++-default-type __type__++ <:CompileTimeOptions: compile-time option>.
663 By default, the following types are equivalent:
665 int = Int.int = Int32.int
666 real = Real.real = Real64.real
667 word = Word.word = Word32.word
670 == Real and Math functions ==
672 The `Real`, `Real32`, and `Real64` modules are implemented
673 using the `C` math library, so the SML functions will reflect the
674 behavior of the underlying library function. We have made some effort
675 to unify the differences between the math libraries on different
676 platforms, and in particular to handle exceptional cases according to
677 the Basis Library specification. However, there will be differences
678 due to different numerical algorithms and cases we may have missed.
679 Please submit a <:Bug:bug report> if you encounter an error in
680 the handling of an exceptional case.
682 On x86, real arithmetic is implemented internally using 80 bits of
683 precision. Using higher precision for intermediate results in
684 computations can lead to different results than if all the computation
685 is done at 32 or 64 bits. If you require strict IEEE compliance, you
686 can compile with `-ieee-fp true`, which will cause intermediate
687 results to be stored after each operation. This may cause a
688 substantial performance penalty.