-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathBuiltins.fs
More file actions
264 lines (194 loc) · 6.59 KB
/
Builtins.fs
File metadata and controls
264 lines (194 loc) · 6.59 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/// Type bindings for Python builtins: https://docs.python.org/3/library/functions.html#built-in-funcs
module Fable.Python.Builtins
open System
open System.Collections.Generic
open Fable.Core
// fsharplint:disable MemberNames,InterfaceNames
type TextIOBase =
abstract read: unit -> string
abstract read: __size: int -> string
abstract write: __s: string -> int
abstract writelines: __lines: string seq -> unit
abstract readline: __size: int -> string
abstract readlines: __hint: int -> string list
abstract tell: unit -> int
type TextIOWrapper =
inherit IDisposable
inherit TextIOBase
module OpenTextMode =
[<Literal>]
let ReadUpdate = "r+"
[<Literal>]
let UpdateRead = "+r"
[<Literal>]
let ReadTextUpdate = "rt+"
[<Literal>]
let ReadUpdateText = "r+t"
[<Literal>]
let UpdateReadText = "+rt"
[<Literal>]
let TextReadUpdate = "tr+"
[<Literal>]
let TextUpdateRead = "t+r"
[<Literal>]
let UpdateTextRead = "+tr"
[<Literal>]
let WriteUpdate = "w+"
[<Literal>]
let UpdateWrite = "+w"
[<Literal>]
let WriteTextUpdate = "wt+"
[<Literal>]
let WriteUpdateText = "w+t"
[<Literal>]
let UpdateWriteText = "+wt"
[<Literal>]
let TextWriteUpdate = "tw+"
[<Literal>]
let TextUpdateWrite = "t+w"
[<Literal>]
let UpdateTextWrite = "+tw"
[<Literal>]
let AppendUpdate = "a+"
[<Literal>]
let UpdateAppend = "+a"
[<Literal>]
let AppendTextUpdate = "at+"
[<Literal>]
let AppendUpdateText = "a+t"
[<Literal>]
let UpdateAppendText = "+at"
[<Literal>]
let TextAppendUpdate = "ta+"
[<Literal>]
let TextUpdateAppend = "t+a"
[<Literal>]
let UpdateTextAppend = "+ta"
[<Literal>]
let CreateUpdate = "x+"
[<Literal>]
let UpdateCreate = "+x"
[<Literal>]
let CreateTextUpdate = "xt+"
[<Literal>]
let CreateUpdateText = "x+t"
[<Literal>]
let UpdateCreateText = "+xt"
[<Literal>]
let TextCreateUpdate = "tx+"
[<Literal>]
let TextUpdateCreate = "t+x"
[<Literal>]
let UpdateTextCreate = "+tx"
[<Literal>]
let Read = "rt"
[<Literal>]
let ReadText = "rt"
[<Literal>]
let TextRead = "tr"
[<Literal>]
let Write = "w"
[<Literal>]
let WriteText = "wt"
[<Literal>]
let TextWrite = "tw"
[<Literal>]
let Append = "a"
[<Literal>]
let AppendText = "at"
[<Literal>]
let TextAppend = "ta"
[<Literal>]
let Create = "x"
[<Literal>]
let CreateText = "xt"
[<Literal>]
let TextCreate = "tx"
type _Opener = Tuple<string, int> -> int
[<Erase>]
type IExports =
/// Return the absolute value of the argument.
abstract abs: int -> int
/// Return the absolute value of the argument.
abstract abs: float -> float
/// Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.
abstract chr: int -> char
/// Return the names in the current scope.
abstract dir: unit -> string list
/// Return an alphabetized list of names comprising (some of) the
/// attributes of the given object, and of attributes reachable from
/// it
abstract dir: obj -> string list
/// Return the identity of an object.
abstract id: obj -> int
///Return the length (the number of items) of an object. The argument may
///be a sequence (such as a string, bytes, tuple, list, or range) or a
///collection (such as a dictionary, set, or frozen set).
abstract len: obj -> int
/// Make an iterator that computes the function using arguments from
/// the iterable. Stops when iterable is exhausted.
abstract map: ('T1 -> 'T2) * IEnumerable<'T1> -> IEnumerable<'T2>
/// Make an iterator that computes the function using arguments from each
/// of the iterables. Stops when the shortest iterable is exhausted.
abstract map: ('T1 * 'T2 -> 'T3) * IEnumerable<'T1> * IEnumerable<'T2> -> IEnumerable<'T3>
/// Make an iterator that computes the function using arguments from each
/// of the iterables. Stops when the shortest iterable is exhausted.
abstract map: ('T1 * 'T2 * 'T3 -> 'T4) * IEnumerable<'T1> * IEnumerable<'T2> * IEnumerable<'T3> -> IEnumerable<'T4>
/// Return the Unicode code point for a one-character string.
abstract ord: char -> int
/// Object to string
abstract str: obj -> string
/// Object to int
abstract int: obj -> int
/// Object to float
abstract float: obj -> float
/// Return the largest item in an iterable or the largest of two or more arguments.
abstract max: 'T * 'T -> 'T
/// Return the largest item in an iterable or the largest of two or more arguments.
abstract max: 'T * 'T * 'T -> 'T
/// Return the largest item in an iterable or the largest of two or more arguments.
abstract max: IEnumerable<'T> -> 'T
/// Return the smallest item in an iterable or the smallest of two or more arguments.
abstract min: 'T * 'T -> 'T
/// Return the smallest item in an iterable or the smallest of two or more arguments.
abstract min: 'T * 'T * 'T -> 'T
/// Return the smallest item in an iterable or the smallest of two or more arguments.
abstract min: IEnumerable<'T> -> 'T
/// Return the sum of a 'start' value (default: 0) plus an iterable of numbers.
abstract sum: IEnumerable<'T> -> 'T
/// Return True if bool(x) is True for all values x in the iterable.
abstract all: IEnumerable<bool> -> bool
/// Return True if bool(x) is True for any x in the iterable.
abstract any: IEnumerable<bool> -> bool
abstract print: obj: obj -> unit
[<NamedParams(fromIndex = 1)>]
abstract ``open``:
file: int *
?mode: string *
?buffering: int *
?encoding: string *
?errors: string *
?newline: string *
?closefd: bool *
?opener: _Opener ->
TextIOWrapper
[<NamedParams(fromIndex = 1)>]
abstract ``open``:
file: string *
?mode: string *
?buffering: int *
?encoding: string *
?errors: string *
?newline: string *
?closefd: bool *
?opener: _Opener ->
TextIOWrapper
[<ImportAll("builtins")>]
let builtins: IExports = nativeOnly
// NOTE: Below we can add builtins that don't require overloads, and do not
// conflict with common F# or .NET functions. If they do we keep them in
// `IExports` above.
[<Emit("__name__")>]
let __name__: string = nativeOnly
/// Python print function. Takes a single argument, so can be used with e.g string interpolation.
let print obj = builtins.print obj