Source

amall / src / it_type.ml

  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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
module type IT
 =
  sig
    module It_IO :
      sig
        type m +'a;
        value return : 'a -> m 'a;
        value bind : ('a -> m 'b) -> m 'a -> m 'b;
        value bind_rev : m 'a -> ('a -> m 'b) -> m 'b;
        value error : exn -> m 'a;
        value catch : (unit -> m 'a) -> (exn -> m 'a) -> m 'a;
        type output_channel;
        value stdout : output_channel;
        value write : output_channel -> string -> m unit;
(*
        value write_from : output_channel -> string -> int -> int -> m int;
*)
        type input_channel;
        value open_in : string -> m input_channel;
        value close_in : input_channel -> m unit;
        value read_into : input_channel -> string -> int -> int -> m int;
        value runIO : m 'a -> [= `Error of exn | `Ok of 'a ];
      end;
    module Subarray :
      sig
        module C :
          sig
            type t 'a =
              private
                { arr : array 'a; ofs : int; len : int };
            value empty : t 'a;
            value mk : ~arr:array 'a -> ~ofs:int -> ~len:int -> t 'a;
          end;
        type t 'a =
          C.t 'a == private
            { arr : array 'a; ofs : int; len : int };
        value length : t 'a -> int;
        value get : t 'a -> int -> 'a;
        value empty : C.t 'a;
        value replace_with_substring :
          array char -> string -> int -> int -> C.t char;
        value of_string : string -> C.t char;
        value of_array : array 'a -> C.t 'a;
        value of_array_sub : array 'a -> int -> int -> C.t 'a;
        value of_list : list 'a -> C.t 'a;
        value of_elem : 'a -> C.t 'a;
        type dir = Subarray.dir == [ L | R ];
        value fold : dir -> ('a -> 'b -> 'a) -> 'a -> C.t 'b -> 'a;
        value iter : ('a -> unit) -> C.t 'a -> unit;
        value to_list : C.t 'a -> list 'a;
        value to_string : C.t char -> string;
        value append_to_list_rev : C.t 'a -> list 'a -> list 'a;
        value get_first_item : C.t 'a -> option 'a;
        value destruct_first_item : C.t 'a -> option ('a * C.t 'a);
        value sub : C.t 'a -> ~ofs:int -> ~len:int -> C.t 'a;
        value split_at : int -> C.t 'a -> (C.t 'a * C.t 'a);
        value drop : int -> C.t 'a -> C.t 'a;
        value break : ('a -> bool) -> C.t 'a -> (C.t 'a * C.t 'a);
        value break_limit :
          ~limit:int ->
          ('a -> bool) ->
          C.t 'a -> [> `Found of (C.t 'a * C.t 'a) | `Hit_end | `Hit_limit ];
        value drop_while : ('a -> bool) -> C.t 'a -> C.t 'a;
        value is_empty : C.t 'a -> bool;
        value buffer_add : Buffer.t -> C.t char -> unit;
        value map : ('a -> 'b) -> C.t 'a -> C.t 'b;
        value copy : C.t 'a -> C.t 'a;
        value concat_splitted : C.t 'a -> C.t 'a -> C.t 'a;
      end;
    module S :
      sig
        module C :
          sig
            type t 'a =
              Subarray.C.t 'a == private
                { arr : array 'a; ofs : int; len : int };
            value empty : t 'a;
            value mk : ~arr:array 'a -> ~ofs:int -> ~len:int -> t 'a;
          end;
        type t 'a =
          Subarray.C.t 'a == private
            { arr : array 'a; ofs : int; len : int };
        value length : t 'a -> int;
        value get : t 'a -> int -> 'a;
        value empty : C.t 'a;
        value replace_with_substring :
          array char -> string -> int -> int -> C.t char;
        value of_string : string -> C.t char;
        value of_array : array 'a -> C.t 'a;
        value of_array_sub : array 'a -> int -> int -> C.t 'a;
        value of_list : list 'a -> C.t 'a;
        value of_elem : 'a -> C.t 'a;
        type dir = Subarray.dir == [ L | R ];
        value fold : dir -> ('a -> 'b -> 'a) -> 'a -> C.t 'b -> 'a;
        value iter : ('a -> unit) -> C.t 'a -> unit;
        value to_list : C.t 'a -> list 'a;
        value to_string : C.t char -> string;
        value append_to_list_rev : C.t 'a -> list 'a -> list 'a;
        value get_first_item : C.t 'a -> option 'a;
        value destruct_first_item : C.t 'a -> option ('a * C.t 'a);
        value sub : C.t 'a -> ~ofs:int -> ~len:int -> C.t 'a;
        value split_at : int -> C.t 'a -> (C.t 'a * C.t 'a);
        value drop : int -> C.t 'a -> C.t 'a;
        value break : ('a -> bool) -> C.t 'a -> (C.t 'a * C.t 'a);
        value break_limit :
          ~limit:int ->
          ('a -> bool) ->
          C.t 'a -> [> `Found of (C.t 'a * C.t 'a) | `Hit_end | `Hit_limit ];
        value drop_while : ('a -> bool) -> C.t 'a -> C.t 'a;
        value is_empty : C.t 'a -> bool;
        value buffer_add : Buffer.t -> C.t char -> unit;
        value map : ('a -> 'b) -> C.t 'a -> C.t 'b;
        value copy : C.t 'a -> C.t 'a;
        value concat_splitted : C.t 'a -> C.t 'a -> C.t 'a;
      end;
    type err_msg = exn;
    exception EIO of (exn * It_Types.place);
    exception Iteratees_err_msg of err_msg;
    exception Divergent_iteratee of It_Types.place;
    value ierr_of_merr : err_msg -> err_msg;
    type stream 'a =

        [ EOF of option err_msg | Chunk of Subarray.t 'a ];
    value chunk_of : 'a -> stream 'a;
    value dbgstream : ?addon:string -> stream 'a -> string;
    value dbgstream_char : ?body:int -> stream char -> string;
    value ( >>% ) : It_IO.m 'a -> ('a -> It_IO.m 'b) -> It_IO.m 'b;
    value ( %<< ) : ('a -> It_IO.m 'b) -> It_IO.m 'a -> It_IO.m 'b;
    module Sl :
      sig
        type sl 'a;
        value empty : sl 'a;
        value destr_head : sl 'a -> option (stream 'a * sl 'a);
        value cons : stream 'a -> sl 'a -> sl 'a;
        value get_one_opt : sl 'a -> option (stream 'a);
        value one : stream 'a -> sl 'a;
        value dbgsl : sl 'a -> string;
      end;
    type sl 'a = Sl.sl 'a;
    type iteratee 'a 'b =

        [ IE_done of 'b
        | IE_cont of option err_msg and
            stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a) ];
    value return : 'a -> iteratee 'b 'a;
    value bindI : ('a -> iteratee 'b 'c) -> iteratee 'b 'a -> iteratee 'b 'c;
    value ( =<< ) :
      ('a -> iteratee 'b 'c) -> iteratee 'b 'a -> iteratee 'b 'c;
    value ( >>= ) :
      iteratee 'a 'b -> ('b -> iteratee 'a 'c) -> iteratee 'a 'c;
    value lift : It_IO.m 'a -> iteratee 'b 'a;
    value throw_err : err_msg -> iteratee 'a 'b;
    value throw_err_cont :
      err_msg -> stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a);
    value throw_recoverable_err :
      err_msg ->
      (stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a)) -> iteratee 'a 'b;
    value set_eof : stream 'a -> err_msg;
    value empty_stream : stream 'a;
    value ie_doneM : 'a -> stream 'b -> It_IO.m (iteratee 'b 'a * sl 'b);
    value ie_contM :
      (stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a)) ->
      It_IO.m (iteratee 'a 'b * Sl.sl 'c);
    value ie_doneMsl : 'a -> 'b -> It_IO.m (iteratee 'c 'a * 'b);
    value ie_errorMsl : err_msg -> sl 'a -> It_IO.m (iteratee 'a 'b * sl 'a);
    value ie_cont :
      (stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a)) -> iteratee 'a 'b;
    value liftI : It_IO.m (iteratee 'a 'b) -> iteratee 'a 'b;
    value merr_of_ierr : err_msg -> It_IO.m 'a;
    value joinI : iteratee 'a (iteratee 'b 'c) -> iteratee 'a 'c;
    value run : iteratee 'a 'b -> It_IO.m 'b;
    value stream2list : iteratee 'a (list 'a);
    value get_stream_eof : iteratee 'a (option (option err_msg));
    value is_stream_finished : iteratee 'a (option err_msg);
    value break_fold :
      ('a -> bool) -> ('b -> 'a -> 'b) -> 'b -> iteratee 'a 'b;
    value mapI : ('a -> 'b) -> iteratee 'c 'a -> iteratee 'c 'b;
    value break : ('a -> bool) -> iteratee 'a (list 'a);
    value prepend : (unit -> 'a) -> ('a -> iteratee 'b 'c) -> iteratee 'b 'c;
    value break_chars : (char -> bool) -> iteratee char string;
    value drop_while : ('a -> bool) -> iteratee 'a unit;
    value peek : iteratee 'a (option 'a);
    value head : iteratee 'a 'a;
    value pervasives_eq : 'a -> 'a -> bool;
    value heads : ?eq:('a -> 'a -> bool) -> list 'a -> iteratee 'a int;
    value skip_till_eof : iteratee 'a unit;
    value drop_step : int -> stream 'a -> It_IO.m (iteratee 'a unit * sl 'a);
    value drop : int -> iteratee 'a unit;
    value io_iter : ('a -> It_IO.m unit) -> list 'a -> It_IO.m unit;
    value print_line : string -> It_IO.m unit;
    type enumerator 'a 'b = iteratee 'a 'b -> It_IO.m (iteratee 'a 'b);
    value enum_eof : enumerator 'a 'b;
    value enum_err : err_msg -> enumerator 'a 'b;
    value ( >>> ) : enumerator 'a 'b -> enumerator 'a 'b -> enumerator 'a 'b;
    value enum_pure_1chunk : list 'a -> enumerator 'a 'b;
    value enum_pure_nchunk : list 'a -> int -> enumerator 'a 'b;
    value enum_string : ?chunk_size:int -> string -> enumerator char 'a;
    value mprintf : format4 'a unit string (It_IO.m unit) -> 'a;
    value mres : It_IO.m 'a -> It_IO.m (It_Types.res 'a);
    value _munres : It_Types.res 'a -> It_IO.m 'a;
    value enum_readchars :
      ~buffer_size:int ->
      ~read_func:('a -> string -> int -> int -> It_IO.m int) ->
      'a -> enumerator char 'b;
    value enum_fd : It_IO.input_channel -> enumerator char 'a;
    value enum_file : string -> enumerator char 'a;
    type enumeratee 'a 'b 'c = iteratee 'b 'c -> iteratee 'a (iteratee 'b 'c);
    value take_gen : [= `Drop | `Fail ] -> int -> enumeratee 'a 'a 'b;
    value take : int -> iteratee 'a 'b -> iteratee 'a (iteratee 'a 'b);
    value take_or_fail :
      int -> iteratee 'a 'b -> iteratee 'a (iteratee 'a 'b);
    value map_stream : ('a -> 'b) -> enumeratee 'a 'b 'c;
    value sequence_stream : iteratee 'a 'b -> enumeratee 'a 'b 'c;
    value enum_words : enumeratee char string 'a;
    value array_ensure_size :
      ~default:'a -> ref (array 'a) -> int -> array 'a;
    module SC :
      sig
        type t 'a = Subarray_cat.t 'a;
        value make : list (Subarray.t 'a) -> t 'a;
        value length : t 'a -> int;
        value get : t 'a -> int -> 'a;
        value sub_copy_out : ?ofs:int -> ?len:int -> t 'a -> Subarray.t 'a;
        value append : t 'a -> Subarray.t 'a -> t 'a;
      end;
    type uchar = int;
    module UTF8 :
      sig
        value utf8_of_char : enumeratee char uchar 'a;
      end;
    value break_copy :
      ~cpred:(char -> bool) ->
      ~outch:It_IO.output_channel -> iteratee char unit;
    value break_limit :
      ~pred:('a -> bool) ->
      ~limit:int ->
      iteratee 'a ([= `Found | `Hit_eof | `Hit_limit ] * Subarray.t 'a);
    value limit : int -> enumeratee 'a 'a 'b;
    value catchk :
      (unit -> iteratee 'a 'b) ->
      (err_msg ->
       (stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a)) -> iteratee 'a 'b) ->
      iteratee 'a 'b;
    value catch :
      (unit -> iteratee 'a 'b) ->
      (err_msg -> iteratee 'a 'b) -> iteratee 'a 'b;
    value printf : format4 'a unit string (iteratee 'b unit) -> 'a;
    value gather_to_string : iteratee char string;
    module Ops :
      sig
        value ( %<< ) : ('a -> It_IO.m 'b) -> It_IO.m 'a -> It_IO.m 'b;
        value ( >>% ) : It_IO.m 'a -> ('a -> It_IO.m 'b) -> It_IO.m 'b;
        value ( =<< ) :
          ('a -> iteratee 'b 'c) -> iteratee 'b 'a -> iteratee 'b 'c;
        value ( >>= ) :
          iteratee 'a 'b -> ('b -> iteratee 'a 'c) -> iteratee 'a 'c;
        value ( >>> ) :
          enumerator 'a 'b -> enumerator 'a 'b -> enumerator 'a 'b;
      end;
    value feedI :
      (stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a)) ->
      stream 'a -> It_IO.m (iteratee 'a 'b);
    value feed_it : iteratee 'a 'b -> stream 'a -> iteratee 'a 'b;
    exception Itlist_empty;
    module Anyresult_lasterror :
      sig
        value itlist_step_firstresult_lasterror :
          list (iteratee 'a 'b) ->
          stream 'a ->
          It_IO.m
            [= `Cont of list (iteratee 'a 'b)
             | `First_result of (iteratee 'a 'b * sl 'a)
             | `Last_error of err_msg ];
        value get_any_done : list (iteratee 'a 'b) -> option (iteratee 'c 'b);
        value itlist_anyresult_lasterror :
          list (iteratee 'a 'b) -> iteratee 'a 'b;
      end;
    value itlist_anyresult_lasterror :
      list (iteratee 'a 'b) -> iteratee 'a 'b;
    value junk : iteratee 'a unit;
    exception SInt_overflow;
    exception SInt_not_a_number of string;
    module Reading_ints :
      sig
        value read_uint : iteratee char int;
        value read_uint_nz : iteratee char int;
        value read_int : iteratee char int;
        value read_int_nz : iteratee char int;
        value read_uint32 : iteratee char int32;
        value read_uint32_nz : iteratee char int32;
        value read_int32 : iteratee char int32;
        value read_int32_nz : iteratee char int32;
        value read_uint64 : iteratee char int64;
        value read_uint64_nz : iteratee char int64;
        value read_int64 : iteratee char int64;
        value read_int64_nz : iteratee char int64;
      end;
    value read_uint : iteratee char int;
    value read_uint_nz : iteratee char int;
    value read_int : iteratee char int;
    value read_int_nz : iteratee char int;
    value read_uint32 : iteratee char int32;
    value read_uint32_nz : iteratee char int32;
    value read_int32 : iteratee char int32;
    value read_int32_nz : iteratee char int32;
    value read_uint64 : iteratee char int64;
    value read_uint64_nz : iteratee char int64;
    value read_int64 : iteratee char int64;
    value read_int64_nz : iteratee char int64;
    module type NUM =
      sig
        type num;
        value num_of_int : int -> num;
        value mult_num : num -> num -> num;
        value power_num : num -> num -> num;
        value num_of_string : string -> num;
      end;
    module Reading_num :
      functor (Num : NUM) ->
        sig
          value num_fix_unsigned : iteratee char Num.num;
          value num_fix : iteratee char Num.num;
          value num_of_string_fix : string -> It_IO.m Num.num;
        end;
    module Base64 :
      sig
        value base64_conv_table : string;
        exception Bad_encoding;
        value base64_decode_char : char -> int;
        value base64_decode_piece :
          ~ibuf:array int -> ~arr_to:array char -> ~arr_ofs:int -> unit;
        value base64_decode :
          ~s_from:S.t char ->
          ~arr_to:array char ->
          ~ibuf:array int -> ~ipos:ref int -> (int * bool * bool);
        value base64_decode_last :
          ~arr_to:array char ->
          ~ibuf:array int -> ~ipos_val:int -> (int * bool);
        value enee_cont :
          iteratee 'a 'b ->
          ((stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a)) ->
           iteratee 'c (iteratee 'a 'b)) ->
          iteratee 'c (iteratee 'a 'b);
        value enee_cont_io :
          iteratee 'a 'b ->
          ((stream 'a -> It_IO.m (iteratee 'a 'b * sl 'a)) ->
           It_IO.m (iteratee 'c (iteratee 'a 'b) * sl 'c)) ->
          It_IO.m (iteratee 'c (iteratee 'a 'b) * sl 'c);
        value enee_base64_decode :
          iteratee char 'a -> iteratee char (iteratee char 'a);
        value step :
          array int ->
          ref int ->
          ref (array char) ->
          (stream char -> It_IO.m (iteratee char 'a * sl char)) ->
          stream char -> It_IO.m (iteratee char (iteratee char 'a) * sl char);
        value finish :
          ~obuf:ref (array char) ->
          ~ibuf:array int ->
          ~ipos:ref int ->
          ~opt_err:option err_msg ->
          (stream char -> It_IO.m (iteratee char 'a * sl char)) ->
          It_IO.m (iteratee char (iteratee char 'a) * sl char);
        value pass_obuf :
          ~written:int ->
          ~arr_to:array char ->
          (stream char -> It_IO.m (iteratee char 'a * sl char)) ->
          It_IO.m (iteratee char 'a);
        value ret :
          ~opt_err:option err_msg ->
          (stream char -> It_IO.m (iteratee char 'a * sl char)) ->
          It_IO.m (iteratee char (iteratee char 'a) * sl char);
      end;
    value base64_decode :
      iteratee char 'a -> iteratee char (iteratee char 'a);
    module Deque_stream :
      sig
        type t 'a;
        value empty : t 'a;
        value cons : int -> stream 'a -> t 'a -> t 'a;
        value cons_sl : sl 'a -> t 'a -> t 'a;
        value snoc : t 'a -> int -> stream 'a -> t 'a;
        value concat : t 'a -> sl 'a;
        value destr_head : t 'a -> option ((int * stream 'a) * t 'a);
        value is_empty : t 'a -> bool;
      end;
    value fdbg : format4 'a unit string unit -> 'a;
    value break_subsequence :
      (S.t 'a -> int -> option (It_IO.m (iteratee 'a 'b * sl 'a))) ->
      iteratee 'a 'c -> iteratee 'a (option 'b * iteratee 'a 'c);
    value it_ignore : iteratee 'a unit;
    value it_ignore_step : stream 'a -> It_IO.m (iteratee 'a unit * sl 'a);
    value map_ready : iteratee 'a 'b -> iteratee 'c 'b;
    value eof_to_res :
      iteratee 'a 'b ->
      option err_msg -> iteratee 'c [= `Error of err_msg | `Ok of 'b ];
    value probe_string :
      string ->
      S.t char -> int -> option (It_IO.m (iteratee char unit * sl char));
    value it_last : int -> iteratee 'a (list 'a);

    type enumpart 'el 'a = sl 'el -> iteratee 'el 'a ->
      enumpart_ret 'el 'a
    and enumpart_ret 'el 'a =
      It_IO.m (iteratee 'el 'a * Lazy.t (sl 'el) * opt_enumpart 'el)
    and opt_enumpart 'el =
      (* to avoid -rectypes *)
      [ EP_None
      | EP_Some of enumpart_poly 'el
      ]
    and enumpart_poly 'el =
      { enumpart_poly : ! 'a . enumpart 'el 'a
      }
    ;

    value enumpart_readchars
     :
       ~buffer_size:int ->
       ~read_func:('ch -> string -> int (*ofs*) -> int (*len*)
                   -> It_IO.m int
                  ) ->
       'ch ->
       enumpart char 'a
    ;

    type it_exact =
      [= `Done
      |  `Eof of (int * option err_msg)
      ]
    ;

    value take_exact : int -> iteratee 'el 'a ->
      iteratee 'el (it_exact * iteratee 'el 'a)
    ;

  end
;