Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / basis-library / primitive / prim1.sml
CommitLineData
7f918cf1
CE
1(* Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 *)
8
9(* Primitive names are special -- see atoms/prim.fun. *)
10
11structure Primitive = struct
12
13open Primitive
14
15structure GetSet =
16 struct
17 type 'a t = (unit -> 'a) * ('a -> unit)
18 end
19
20structure PreThread :> sig type t end = struct type t = Thread.t end
21structure Thread :> sig type t end = struct type t = Thread.t end
22
23(**************************************************************************)
24
25structure Bool =
26 struct
27 open Bool
28 fun not b = if b then false else true
29 end
30
31structure Controls =
32 struct
33 val debug = _command_line_const "MLton.debug": bool = false;
34 val detectOverflow = _command_line_const "MLton.detectOverflow": bool = true;
35 val safe = _command_line_const "MLton.safe": bool = true;
36 val bufSize = _command_line_const "TextIO.bufSize": Int32.int = 4096;
37 end
38
39structure Exn =
40 struct
41 open Exn
42
43 val name = _prim "Exn_name": exn -> String8.string;
44
45 exception Div
46 exception Domain
47 exception Fail8 of String8.string
48 exception Fail16 of String16.string
49 exception Fail32 of String32.string
50 exception Overflow
51 exception Size
52 exception Span
53 exception Subscript
54
55 val wrapOverflow: ('a -> 'b) -> ('a -> 'b) =
56 fn f => fn a => f a handle PrimOverflow => raise Overflow
57 end
58
59structure Order =
60 struct
61 datatype t = LESS | EQUAL | GREATER
62 datatype order = datatype t
63 end
64
65structure Option =
66 struct
67 datatype 'a t = NONE | SOME of 'a
68 datatype option = datatype t
69 end
70
71structure Ref =
72 struct
73 open Ref
74 val deref = _prim "Ref_deref": 'a ref -> 'a;
75 val assign = _prim "Ref_assign": 'a ref * 'a -> unit;
76 end
77
78structure TopLevel =
79 struct
80 val getHandler = _prim "TopLevel_getHandler": unit -> (exn -> unit);
81 val getSuffix = _prim "TopLevel_getSuffix": unit -> (unit -> unit);
82 val setHandler = _prim "TopLevel_setHandler": (exn -> unit) -> unit;
83 val setSuffix = _prim "TopLevel_setSuffix": (unit -> unit) -> unit;
84 end
85
86end
87
88val not = Primitive.Bool.not
89
90exception Bind = Primitive.Exn.Bind
91exception Div = Primitive.Exn.Div
92exception Domain = Primitive.Exn.Domain
93exception Match = Primitive.Exn.Match
94exception Overflow = Primitive.Exn.Overflow
95exception Size = Primitive.Exn.Size
96exception Span = Primitive.Exn.Span
97exception Subscript = Primitive.Exn.Subscript
98
99datatype option = datatype Primitive.Option.option
100datatype order = datatype Primitive.Order.order
101
102infix 4 = <>
103val op = = _prim "MLton_equal": ''a * ''a -> bool;
104val op <> = fn (x, y) => not (x = y)