-
Notifications
You must be signed in to change notification settings - Fork 2
/
pervasives.coop
47 lines (39 loc) · 1.75 KB
/
pervasives.coop
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(* Pervasives loaded at startup. *)
(* Exceptions that are used by builtin functions. Make sure they are
in synch with src/external.ml *)
exception division_by_zero of unit
exception malformed_integer of unit
operation print_int : int -> unit
operation print_string : string -> unit
operation read_int : unit -> int {!malformed_integer}
operation read_string : unit -> string
operation flush_stdout : unit -> unit
type io_container = {print_int, print_string, read_int, read_string, flush_stdout}
type in_channel
type out_channel
exception sys_error of string
exception end_of_file of unit
operation open_in : string -> in_channel {!sys_error}
operation close_in : in_channel -> unit {!sys_error}
operation input_line : in_channel -> string {!sys_error, !end_of_file}
operation open_out : string -> out_channel {!sys_error}
operation close_out : out_channel -> unit {!sys_error}
operation output_string : out_channel -> (string -> unit {!sys_error})
operation flush_out : out_channel -> unit {!sys_error}
type file_container = {open_in, close_in, input_line, open_out, close_out, output_string, flush_out}
external pure : {} = "pure"
external stdio : io_container = "stdio"
external file : file_container = "file"
(* Arithmetic *)
external ( + ) : int -> int -> int = "+"
external ( - ) : int -> int -> int = "-"
external ( * ) : int -> int -> int = "*"
external ( / ) : int -> int -> int {!division_by_zero} = "/"
external ( % ) : int -> int -> int = "%"
external ( <> ) : int -> int -> bool = "<>"
external ( < ) : int -> int -> bool = "<"
external ( > ) : int -> int -> bool = ">"
external ( <= ) : int -> int -> bool = "<="
external ( >= ) : int -> int -> bool = ">="
external ( ^ ) : string -> string -> string = "^"
external string_of_int : int -> string = "string_of_int"