forked from miking-lang/miking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile-ext.ext-ocaml.mc
107 lines (105 loc) · 2.88 KB
/
file-ext.ext-ocaml.mc
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
include "ocaml/ast.mc"
let fileExtMap =
use OCamlTypeAst in
mapFromSeq cmpString
[
("fileExists", [
{ expr = "(fun s -> try Sys.file_exists s with _ -> false)",
ty = tyarrows_ [otystring_, tybool_],
libraries = [],
cLibraries = []
}
]),
("deleteFile", [
{ expr = "(fun s -> try Sys.remove s with _ -> ())",
ty = tyarrows_ [otystring_, otyunit_],
libraries = [],
cLibraries = []
}
]),
("fileSize", [
{ expr = concat "(fun n -> try let f = open_in_bin n in let s = in_channel_length "
"f in let _ = close_in_noerr f in s with _ -> 0)",
ty = tyarrows_ [otystring_, tyint_],
libraries = [],
cLibraries = []
}
]),
("writeOpen", [
{ expr = "(fun s -> try (open_out_bin s, true) with _ -> (stdout, false))",
ty = tyarrows_ [otystring_, otytuple_ [otyvarext_ "out_channel" [], tybool_]],
libraries = [],
cLibraries = []
}
]),
("writeString", [
{ expr = "output_string",
ty = tyarrows_ [otyvarext_ "out_channel" [], otystring_, otyunit_],
libraries = [],
cLibraries = []
}
]),
("writeFlush", [
{ expr = "flush",
ty = tyarrows_ [otyvarext_ "out_channel" [], otyunit_],
libraries = [],
cLibraries = []
}
]),
("writeClose", [
{ expr = "close_out_noerr",
ty = tyarrows_ [otyvarext_ "out_channel" [], otyunit_],
libraries = [],
cLibraries = []
}
]),
("readOpen", [
{ expr = "(fun s -> try (open_in_bin s, true) with _ -> (stdin, false))",
ty = tyarrows_ [otystring_, otytuple_ [otyvarext_ "in_channel" [], tybool_]],
libraries = [],
cLibraries = []
}
]),
("readLine", [
{ expr = "(fun rc -> try (input_line rc, false) with | End_of_file -> (\"\",true))",
ty = tyarrows_ [otyvarext_ "in_channel" [], otytuple_ [otystring_, tybool_]],
libraries = [],
cLibraries = []
}
]),
("readString", [
{ expr = "(fun f -> try really_input_string f (in_channel_length f) with _ -> \"\")",
ty = tyarrows_ [otyvarext_ "in_channel" [], otystring_],
libraries = [],
cLibraries = []
}
]),
("readClose", [
{ expr = "close_in_noerr",
ty = tyarrows_ [otyvarext_ "in_channel" [], otyunit_],
libraries = [],
cLibraries = []
}
]),
("stdin", [
{ expr = "stdin",
ty = otyvarext_ "in_channel" [],
libraries = [],
cLibraries = []
}
]),
("stdout", [
{ expr = "stdout",
ty = otyvarext_ "out_channel" [],
libraries = [],
cLibraries = []
}
]),
("stderr", [
{ expr = "stderr",
ty = otyvarext_ "out_channel" [],
libraries = [],
cLibraries = []
}
])
]