1 (* Copyright (C
) 1999-2007 Henry Cejtin
, Matthew Fluet
, Suresh
2 * Jagannathan
, and Stephen Weeks
.
3 * Copyright (C
) 1997-2000 NEC Research Institute
.
5 * MLton is released under a BSD
-style license
.
6 * See the file MLton
-LICENSE for details
.
9 (* Primitive names are special
-- see atoms
/prim
.fun. *)
11 structure Primitive
= struct
17 type 'a t
= (unit
-> 'a
) * ('a
-> unit
)
20 structure PreThread
:> sig type t
end = struct type t
= Thread
.t
end
21 structure Thread
:> sig type t
end = struct type t
= Thread
.t
end
23 (**************************************************************************)
28 fun not b
= if b
then false else true
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;
43 val name
= _prim
"Exn_name": exn
-> String8
.string;
47 exception Fail8
of String8
.string
48 exception Fail16
of String16
.string
49 exception Fail32
of String32
.string
55 val wrapOverflow
: ('a
-> 'b
) -> ('a
-> 'b
) =
56 fn f
=> fn a
=> f a
handle PrimOverflow
=> raise Overflow
61 datatype t
= LESS | EQUAL | GREATER
62 datatype order
= datatype t
67 datatype 'a t
= NONE | SOME
of 'a
68 datatype option
= datatype t
74 val deref
= _prim
"Ref_deref": 'a ref
-> 'a
;
75 val assign
= _prim
"Ref_assign": 'a ref
* 'a
-> unit
;
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
;
88 val not
= Primitive
.Bool.not
90 exception Bind
= Primitive
.Exn
.Bind
91 exception Div
= Primitive
.Exn
.Div
92 exception Domain
= Primitive
.Exn
.Domain
93 exception Match
= Primitive
.Exn
.Match
94 exception Overflow
= Primitive
.Exn
.Overflow
95 exception Size
= Primitive
.Exn
.Size
96 exception Span
= Primitive
.Exn
.Span
97 exception Subscript
= Primitive
.Exn
.Subscript
99 datatype option
= datatype Primitive
.Option
.option
100 datatype order
= datatype Primitive
.Order
.order
103 val op = = _prim
"MLton_equal": ''a
* ''a
-> bool;
104 val op <> = fn (x
, y
) => not (x
= y
)