1Stdlib(3)                        OCaml library                       Stdlib(3)
2
3
4

NAME

6       Stdlib - The OCaml Standard library.
7

Module

9       Module   Stdlib
10

Documentation

12       Module Stdlib
13        : sig end
14
15
16       The OCaml Standard library.
17
18       This  module  is automatically opened at the beginning of each compila‐
19       tion. All components of this module can therefore be referred by  their
20       short name, without prefixing them by Stdlib .
21
22       In particular, it provides the basic operations over the built-in types
23       (numbers, booleans, byte sequences,  strings,  exceptions,  references,
24       lists, arrays, input-output channels, ...) and the modules .
25
26
27
28
29
30
31
32   Exceptions
33       val raise : exn -> 'a
34
35       Raise the given exception value
36
37
38
39       val raise_notrace : exn -> 'a
40
41       A faster version raise which does not record the backtrace.
42
43
44       Since 4.02.0
45
46
47
48       val invalid_arg : string -> 'a
49
50       Raise exception Invalid_argument with the given string.
51
52
53
54       val failwith : string -> 'a
55
56       Raise exception Failure with the given string.
57
58
59
60       exception Exit
61
62
63       The  Exit  exception is not raised by any library function.  It is pro‐
64       vided for use in your programs.
65
66
67
68       exception Match_failure of (string * int * int)
69
70
71       Exception raised when none of the cases of  a  pattern-matching  apply.
72       The  arguments are the location of the match keyword in the source code
73       (file name, line number, column number).
74
75
76
77       exception Assert_failure of (string * int * int)
78
79
80       Exception raised when an assertion fails. The arguments are  the  loca‐
81       tion  of the assert keyword in the source code (file name, line number,
82       column number).
83
84
85
86       exception Invalid_argument of string
87
88
89       Exception raised by library functions to signal that  the  given  argu‐
90       ments  do not make sense. The string gives some information to the pro‐
91       grammer. As a general rule, this exception should not be caught, it de‐
92       notes  a programming error and the code should be modified not to trig‐
93       ger it.
94
95
96
97       exception Failure of string
98
99
100       Exception raised by library functions to signal that they are undefined
101       on the given arguments. The string is meant to give some information to
102       the programmer; you must not pattern match on the  string  literal  be‐
103       cause it may change in future versions (use Failure _ instead).
104
105
106
107       exception Not_found
108
109
110       Exception  raised by search functions when the desired object could not
111       be found.
112
113
114
115       exception Out_of_memory
116
117
118       Exception raised by the garbage collector when  there  is  insufficient
119       memory  to  complete  the computation. (Not reliable for allocations on
120       the minor heap.)
121
122
123
124       exception Stack_overflow
125
126
127       Exception raised by the bytecode interpreter when the evaluation  stack
128       reaches  its maximal size. This often indicates infinite or excessively
129       deep recursion in the user's program.
130
131       Before 4.10, it was not fully implemented by the native-code compiler.
132
133
134
135       exception Sys_error of string
136
137
138       Exception raised by the input/output functions to report  an  operating
139       system  error. The string is meant to give some information to the pro‐
140       grammer; you must not pattern match on the string  literal  because  it
141       may change in future versions (use Sys_error _ instead).
142
143
144
145       exception End_of_file
146
147
148       Exception  raised by input functions to signal that the end of file has
149       been reached.
150
151
152
153       exception Division_by_zero
154
155
156       Exception raised by integer  division  and  remainder  operations  when
157       their second argument is zero.
158
159
160
161       exception Sys_blocked_io
162
163
164       A  special  case  of  Sys_error  raised  when  no  I/O is possible on a
165       non-blocking I/O channel.
166
167
168
169       exception Undefined_recursive_module of (string * int * int)
170
171
172       Exception raised when an ill-founded  recursive  module  definition  is
173       evaluated.  The  arguments  are  the  location of the definition in the
174       source code (file name, line number, column number).
175
176
177
178
179   Comparisons
180       val (=) : 'a -> 'a -> bool
181
182
183       e1 = e2 tests for structural equality of e1 and e2  .   Mutable  struc‐
184       tures  (e.g. references and arrays) are equal if and only if their cur‐
185       rent contents are structurally equal, even if the two  mutable  objects
186       are  not  the same physical object.  Equality between functional values
187       raises Invalid_argument .  Equality between cyclic data structures  may
188       not terminate.  Left-associative operator, see Ocaml_operators for more
189       information.
190
191
192
193       val (<>) : 'a -> 'a -> bool
194
195       Negation of (=) .  Left-associative operator, see  Ocaml_operators  for
196       more information.
197
198
199
200       val (<) : 'a -> 'a -> bool
201
202       See (>=) .  Left-associative operator, see Ocaml_operators for more in‐
203       formation.
204
205
206
207       val (>) : 'a -> 'a -> bool
208
209       See (>=) .  Left-associative operator,  see  Ocaml_operators  for  more
210       information.
211
212
213
214       val (<=) : 'a -> 'a -> bool
215
216       See  (>=)  .   Left-associative operator,  see Ocaml_operators for more
217       information.
218
219
220
221       val (>=) : 'a -> 'a -> bool
222
223       Structural ordering functions. These functions coincide with the  usual
224       orderings over integers, characters, strings, byte sequences and float‐
225       ing-point numbers, and extend them to a total ordering over all  types.
226       The ordering is compatible with ( = ) . As in the case of ( = ) , muta‐
227       ble structures are compared by contents.  Comparison between functional
228       values  raises Invalid_argument .  Comparison between cyclic structures
229       may not terminate.  Left-associative operator, see Ocaml_operators  for
230       more information.
231
232
233
234       val compare : 'a -> 'a -> int
235
236
237       compare  x  y returns 0 if x is equal to y , a negative integer if x is
238       less than y , and a positive integer if x is greater than y .  The  or‐
239       dering  implemented by compare is compatible with the comparison predi‐
240       cates = , < and > defined above,  with one difference on the  treatment
241       of  the  float value nan .  Namely, the comparison predicates treat nan
242       as different from any other float value, including itself;  while  com‐
243       pare treats nan as equal to itself and less than any other float value.
244       This treatment of nan ensures that compare defines a total ordering re‐
245       lation.
246
247
248       compare applied to functional values may raise Invalid_argument .  com‐
249       pare applied to cyclic structures may not terminate.
250
251       The compare function can be used as the comparison function required by
252       the  Set.Make  and  Map.Make functors, as well as the List.sort and Ar‐
253       ray.sort functions.
254
255
256
257       val min : 'a -> 'a -> 'a
258
259       Return the smaller of the two arguments.  The result is unspecified  if
260       one of the arguments contains the float value nan .
261
262
263
264       val max : 'a -> 'a -> 'a
265
266       Return  the greater of the two arguments.  The result is unspecified if
267       one of the arguments contains the float value nan .
268
269
270
271       val (==) : 'a -> 'a -> bool
272
273
274       e1 == e2 tests for physical equality of e1 and e2 .  On  mutable  types
275       such as references, arrays, byte sequences, records with mutable fields
276       and objects with mutable instance variables, e1 == e2 is  true  if  and
277       only  if  physical modification of e1 also affects e2 .  On non-mutable
278       types, the behavior of ( == ) is implementation-dependent; however,  it
279       is  guaranteed that e1 == e2 implies compare e1 e2 = 0 .  Left-associa‐
280       tive operator,  see Ocaml_operators for more information.
281
282
283
284       val (!=) : 'a -> 'a -> bool
285
286       Negation of (==) .  Left-associative operator,  see Ocaml_operators for
287       more information.
288
289
290
291
292   Boolean operations
293       val not : bool -> bool
294
295       The boolean negation.
296
297
298
299       val (&&) : bool -> bool -> bool
300
301       The boolean 'and'. Evaluation is sequential, left-to-right: in e1 && e2
302       , e1 is evaluated first, and if it returns false , e2 is not  evaluated
303       at  all.  Right-associative operator,  see Ocaml_operators for more in‐
304       formation.
305
306
307
308       val (||) : bool -> bool -> bool
309
310       The boolean 'or'. Evaluation is sequential, left-to-right: in e1 ||  e2
311       ,  e1  is evaluated first, and if it returns true , e2 is not evaluated
312       at all.  Right-associative operator,  see Ocaml_operators for more  in‐
313       formation.
314
315
316
317
318   Debugging
319       val __LOC__ : string
320
321
322       __LOC__  returns  the  location at which this expression appears in the
323       file currently being parsed by the compiler, with  the  standard  error
324       format of OCaml: "File %S, line %d, characters %d-%d".
325
326
327       Since 4.02.0
328
329
330
331       val __FILE__ : string
332
333
334       __FILE__  returns  the  name  of the file currently being parsed by the
335       compiler.
336
337
338       Since 4.02.0
339
340
341
342       val __LINE__ : int
343
344
345       __LINE__ returns the line number at which this  expression  appears  in
346       the file currently being parsed by the compiler.
347
348
349       Since 4.02.0
350
351
352
353       val __MODULE__ : string
354
355
356       __MODULE__ returns the module name of the file being parsed by the com‐
357       piler.
358
359
360       Since 4.02.0
361
362
363
364       val __POS__ : string * int * int * int
365
366
367       __POS__ returns a tuple (file,lnum,cnum,enum) ,  corresponding  to  the
368       location  at  which this expression appears in the file currently being
369       parsed by the compiler.  file is the current filename,  lnum  the  line
370       number, cnum the character position in the line and enum the last char‐
371       acter position in the line.
372
373
374       Since 4.02.0
375
376
377
378       val __FUNCTION__ : string
379
380
381       __FUNCTION__ returns the name of the current function  or  method,  in‐
382       cluding any enclosing modules or classes.
383
384
385       Since 4.12.0
386
387
388
389       val __LOC_OF__ : 'a -> string * 'a
390
391
392       __LOC_OF__ expr returns a pair (loc, expr) where loc is the location of
393       expr in the file currently being parsed by the compiler, with the stan‐
394       dard error format of OCaml: "File %S, line %d, characters %d-%d".
395
396
397       Since 4.02.0
398
399
400
401       val __LINE_OF__ : 'a -> int * 'a
402
403
404       __LINE_OF__  expr  returns a pair (line, expr) , where line is the line
405       number at which the expression expr appears in the file currently being
406       parsed by the compiler.
407
408
409       Since 4.02.0
410
411
412
413       val __POS_OF__ : 'a -> (string * int * int * int) * 'a
414
415
416       __POS_OF__  expr  returns  a  pair  (loc,expr)  ,  where loc is a tuple
417       (file,lnum,cnum,enum) corresponding to the location at  which  the  ex‐
418       pression  expr  appears  in the file currently being parsed by the com‐
419       piler.  file is the current filename, lnum the line  number,  cnum  the
420       character  position in the line and enum the last character position in
421       the line.
422
423
424       Since 4.02.0
425
426
427
428
429   Composition operators
430       val (|>) : 'a -> ('a -> 'b) -> 'b
431
432       Reverse-application operator: x |> f |> g is exactly equivalent to g (f
433       (x))  .  Left-associative operator, see Ocaml_operators for more infor‐
434       mation.
435
436
437       Since 4.01
438
439
440
441       val (@@) : ('a -> 'b) -> 'a -> 'b
442
443       Application operator: g @@ f @@ x is exactly equivalent to g (f (x))  .
444       Right-associative operator, see Ocaml_operators for more information.
445
446
447       Since 4.01
448
449
450
451
452   Integer arithmetic
453       Integers  are  Sys.int_size bits wide.  All operations are taken modulo
454       2^ Sys.int_size .  They do not fail on overflow.
455
456       val (~-) : int -> int
457
458       Unary negation. You can also write - e instead of ~- e .  Unary  opera‐
459       tor, see Ocaml_operators for more information.
460
461
462
463       val (~+) : int -> int
464
465       Unary  addition. You can also write + e instead of ~+ e .  Unary opera‐
466       tor, see Ocaml_operators for more information.
467
468
469       Since 3.12.0
470
471
472
473       val succ : int -> int
474
475
476       succ x is x + 1 .
477
478
479
480       val pred : int -> int
481
482
483       pred x is x - 1 .
484
485
486
487       val (+) : int -> int -> int
488
489       Integer addition.  Left-associative operator, see  Ocaml_operators  for
490       more information.
491
492
493
494       val (-) : int -> int -> int
495
496       Integer  subtraction.  Left-associative operator, , see Ocaml_operators
497       for more information.
498
499
500
501       val ( * ) : int -> int -> int
502
503       Integer multiplication.  Left-associative operator, see Ocaml_operators
504       for more information.
505
506
507
508       val (/) : int -> int -> int
509
510       Integer division.  Integer division rounds the real quotient of its ar‐
511       guments towards zero.  More precisely, if x >= 0 and y > 0 , x /  y  is
512       the  greatest integer less than or equal to the real quotient of x by y
513       .  Moreover, (- x) / y = x / (- y) = - (x / y) .  Left-associative  op‐
514       erator, see Ocaml_operators for more information.
515
516
517       Raises Division_by_zero if the second argument is 0.
518
519
520
521       val (mod) : int -> int -> int
522
523       Integer  remainder.   If y is not zero, the result of x mod y satisfies
524       the following properties: x = (x / y) * y + x mod y and abs(x mod y) <=
525       abs(y) - 1 .  If y = 0 , x mod y raises Division_by_zero .  Note that x
526       mod y is negative only if x  <  0  .   Left-associative  operator,  see
527       Ocaml_operators for more information.
528
529
530       Raises Division_by_zero if y is zero.
531
532
533
534       val abs : int -> int
535
536
537       abs  x  is  the absolute value of x . On min_int this is min_int itself
538       and thus remains negative.
539
540
541
542       val max_int : int
543
544       The greatest representable integer.
545
546
547
548       val min_int : int
549
550       The smallest representable integer.
551
552
553
554
555   Bitwise operations
556       val (land) : int -> int -> int
557
558       Bitwise logical and.  Left-associative  operator,  see  Ocaml_operators
559       for more information.
560
561
562
563       val (lor) : int -> int -> int
564
565       Bitwise logical or.  Left-associative operator, see Ocaml_operators for
566       more information.
567
568
569
570       val (lxor) : int -> int -> int
571
572       Bitwise logical exclusive or.  Left-associative operator, see Ocaml_op‐
573       erators for more information.
574
575
576
577       val lnot : int -> int
578
579       Bitwise logical negation.
580
581
582
583       val (lsl) : int -> int -> int
584
585
586       n lsl m shifts n to the left by m bits.  The result is unspecified if m
587       < 0 or m > Sys.int_size .  Right-associative operator, see Ocaml_opera‐
588       tors for more information.
589
590
591
592       val (lsr) : int -> int -> int
593
594
595       n  lsr m shifts n to the right by m bits.  This is a logical shift: ze‐
596       roes are inserted regardless of the sign of n .  The result is unspeci‐
597       fied  if  m  < 0 or m > Sys.int_size .  Right-associative operator, see
598       Ocaml_operators for more information.
599
600
601
602       val (asr) : int -> int -> int
603
604
605       n asr m shifts n to the right by m bits.  This is an arithmetic  shift:
606       the sign bit of n is replicated.  The result is unspecified if m < 0 or
607       m > Sys.int_size .  Right-associative operator, see Ocaml_operators for
608       more information.
609
610
611
612
613   Floating-point arithmetic
614       OCaml's floating-point numbers follow the IEEE 754 standard, using dou‐
615       ble precision (64 bits) numbers.  Floating-point operations never raise
616       an  exception  on overflow, underflow, division by zero, etc.  Instead,
617       special IEEE numbers are returned as appropriate, such as infinity  for
618       1.0  /.  0.0  , neg_infinity for -1.0 /. 0.0 , and nan ('not a number')
619       for 0.0 /. 0.0 .  These special numbers then propagate  through  float‐
620       ing-point  computations  as  expected: for instance, 1.0 /. infinity is
621       0.0 , basic arithmetic operations ( +.  , -.  , *.  , /.  ) with nan as
622       an argument return nan , ...
623
624       val (~-.)  : float -> float
625
626       Unary negation. You can also write -. e instead of ~-. e .  Unary oper‐
627       ator, see Ocaml_operators for more information.
628
629
630
631       val (~+.)  : float -> float
632
633       Unary addition. You can also write +. e instead of ~+. e .  Unary oper‐
634       ator, see Ocaml_operators for more information.
635
636
637       Since 3.12.0
638
639
640
641       val (+.)  : float -> float -> float
642
643       Floating-point  addition.   Left-associative operator, see Ocaml_opera‐
644       tors for more information.
645
646
647
648       val (-.)  : float -> float -> float
649
650       Floating-point subtraction.  Left-associative operator, see Ocaml_oper‐
651       ators for more information.
652
653
654
655       val ( *. ) : float -> float -> float
656
657       Floating-point    multiplication.    Left-associative   operator,   see
658       Ocaml_operators for more information.
659
660
661
662       val (/.)  : float -> float -> float
663
664       Floating-point division.  Left-associative operator,  see  Ocaml_opera‐
665       tors for more information.
666
667
668
669       val ( ** ) : float -> float -> float
670
671       Exponentiation.   Right-associative  operator,  see Ocaml_operators for
672       more information.
673
674
675
676       val sqrt : float -> float
677
678       Square root.
679
680
681
682       val exp : float -> float
683
684       Exponential.
685
686
687
688       val log : float -> float
689
690       Natural logarithm.
691
692
693
694       val log10 : float -> float
695
696       Base 10 logarithm.
697
698
699
700       val expm1 : float -> float
701
702
703       expm1 x computes exp x -. 1.0  ,  giving  numerically-accurate  results
704       even if x is close to 0.0 .
705
706
707       Since 3.12.0
708
709
710
711       val log1p : float -> float
712
713
714       log1p  x  computes  log(1.0  +.  x) (natural logarithm), giving numeri‐
715       cally-accurate results even if x is close to 0.0 .
716
717
718       Since 3.12.0
719
720
721
722       val cos : float -> float
723
724       Cosine.  Argument is in radians.
725
726
727
728       val sin : float -> float
729
730       Sine.  Argument is in radians.
731
732
733
734       val tan : float -> float
735
736       Tangent.  Argument is in radians.
737
738
739
740       val acos : float -> float
741
742       Arc cosine.  The argument must fall within the range [-1.0, 1.0] .  Re‐
743       sult is in radians and is between 0.0 and pi .
744
745
746
747       val asin : float -> float
748
749       Arc  sine.   The argument must fall within the range [-1.0, 1.0] .  Re‐
750       sult is in radians and is between -pi/2 and pi/2 .
751
752
753
754       val atan : float -> float
755
756       Arc tangent.  Result is in radians and is between -pi/2 and pi/2 .
757
758
759
760       val atan2 : float -> float -> float
761
762
763       atan2 y x returns the arc tangent of y /. x .  The signs of x and y are
764       used to determine the quadrant of the result.  Result is in radians and
765       is between -pi and pi .
766
767
768
769       val hypot : float -> float -> float
770
771
772       hypot x y returns sqrt(x *. x + y *. y) , that is, the  length  of  the
773       hypotenuse  of  a  right-angled triangle with sides of length x and y ,
774       or, equivalently, the distance of the point (x,y) to origin.  If one of
775       x or y is infinite, returns infinity even if the other is nan .
776
777
778       Since 4.00.0
779
780
781
782       val cosh : float -> float
783
784       Hyperbolic cosine.  Argument is in radians.
785
786
787
788       val sinh : float -> float
789
790       Hyperbolic sine.  Argument is in radians.
791
792
793
794       val tanh : float -> float
795
796       Hyperbolic tangent.  Argument is in radians.
797
798
799
800       val acosh : float -> float
801
802       Hyperbolic  arc  cosine.  The argument must fall within the range [1.0,
803       inf] .  Result is in radians and is between 0.0 and inf .
804
805
806       Since 4.13.0
807
808
809
810       val asinh : float -> float
811
812       Hyperbolic arc sine.  The argument and result  range  over  the  entire
813       real line.  Result is in radians.
814
815
816       Since 4.13.0
817
818
819
820       val atanh : float -> float
821
822       Hyperbolic arc tangent.  The argument must fall within the range [-1.0,
823       1.0] .  Result is in radians and ranges over the entire real line.
824
825
826       Since 4.13.0
827
828
829
830       val ceil : float -> float
831
832       Round above to an integer value.  ceil  f  returns  the  least  integer
833       value greater than or equal to f .  The result is returned as a float.
834
835
836
837       val floor : float -> float
838
839       Round  below to an integer value.  floor f returns the greatest integer
840       value less than or equal to f .  The result is returned as a float.
841
842
843
844       val abs_float : float -> float
845
846
847       abs_float f returns the absolute value of f .
848
849
850
851       val copysign : float -> float -> float
852
853
854       copysign x y returns a float whose absolute value  is  that  of  x  and
855       whose  sign  is that of y .  If x is nan , returns nan .  If y is nan ,
856       returns either x or -. x , but it is not specified which.
857
858
859       Since 4.00.0
860
861
862
863       val mod_float : float -> float -> float
864
865
866       mod_float a b returns the remainder of a with respect to b .   The  re‐
867       turned  value  is  a -. n *. b , where n is the quotient a /. b rounded
868       towards zero to an integer.
869
870
871
872       val frexp : float -> float * int
873
874
875       frexp f returns the pair of the significant and the  exponent  of  f  .
876       When  f is zero, the significant x and the exponent n of f are equal to
877       zero.  When f is non-zero, they are defined by f = x *. 2 ** n and  0.5
878       <= x < 1.0 .
879
880
881
882       val ldexp : float -> int -> float
883
884
885       ldexp x n returns x *. 2 ** n .
886
887
888
889       val modf : float -> float * float
890
891
892       modf f returns the pair of the fractional and integral part of f .
893
894
895
896       val float : int -> float
897
898       Same as float_of_int .
899
900
901
902       val float_of_int : int -> float
903
904       Convert an integer to floating-point.
905
906
907
908       val truncate : float -> int
909
910       Same as int_of_float .
911
912
913
914       val int_of_float : float -> int
915
916       Truncate  the given floating-point number to an integer.  The result is
917       unspecified if the argument is nan or falls outside the range of repre‐
918       sentable integers.
919
920
921
922       val infinity : float
923
924       Positive infinity.
925
926
927
928       val neg_infinity : float
929
930       Negative infinity.
931
932
933
934       val nan : float
935
936       A  special floating-point value denoting the result of an undefined op‐
937       eration such as 0.0 /. 0.0 .  Stands for 'not a  number'.   Any  float‐
938       ing-point operation with nan as argument returns nan as result.  As for
939       floating-point comparisons, = , < , <= , > and >= return false  and  <>
940       returns true if one or both of their arguments is nan .
941
942
943
944       val max_float : float
945
946       The largest positive finite value of type float .
947
948
949
950       val min_float : float
951
952       The smallest positive, non-zero, non-denormalized value of type float .
953
954
955
956       val epsilon_float : float
957
958       The  difference  between  1.0  and  the  smallest exactly representable
959       floating-point number greater than 1.0 .
960
961
962       type fpclass =
963        | FP_normal  (* Normal number, none of the below
964        *)
965        | FP_subnormal  (* Number very close to 0.0, has reduced precision
966        *)
967        | FP_zero  (* Number is 0.0 or -0.0
968        *)
969        | FP_infinite  (* Number is positive or negative infinity
970        *)
971        | FP_nan  (* Not a number: result of an undefined operation
972        *)
973
974
975       The five classes of floating-point numbers, as determined by the  clas‐
976       sify_float function.
977
978
979
980       val classify_float : float -> fpclass
981
982       Return the class of the given floating-point number: normal, subnormal,
983       zero, infinite, or not a number.
984
985
986
987
988   String operations
989       More string operations are provided in module String .
990
991       val (^) : string -> string -> string
992
993       String concatenation.  Right-associative operator, see  Ocaml_operators
994       for more information.
995
996
997       Raises   Invalid_argument   if   the   result   is   longer  then  than
998       Sys.max_string_length bytes.
999
1000
1001
1002
1003   Character operations
1004       More character operations are provided in module Char .
1005
1006       val int_of_char : char -> int
1007
1008       Return the ASCII code of the argument.
1009
1010
1011
1012       val char_of_int : int -> char
1013
1014       Return the character with the given ASCII code.
1015
1016
1017       Raises Invalid_argument if the argument is outside the range 0--255.
1018
1019
1020
1021
1022   Unit operations
1023       val ignore : 'a -> unit
1024
1025       Discard the value of its argument and return () .   For  instance,  ig‐
1026       nore(f x) discards the result of the side-effecting function f .  It is
1027       equivalent to f x; () , except that the latter may generate a  compiler
1028       warning; writing ignore(f x) instead avoids the warning.
1029
1030
1031
1032
1033   String conversion functions
1034       val string_of_bool : bool -> string
1035
1036       Return  the  string representation of a boolean. As the returned values
1037       may be shared, the user should not modify them directly.
1038
1039
1040
1041       val bool_of_string_opt : string -> bool option
1042
1043       Convert the given string to a boolean.
1044
1045       Return None if the string is not "true" or "false" .
1046
1047
1048       Since 4.05
1049
1050
1051
1052       val bool_of_string : string -> bool
1053
1054       Same   as   bool_of_string_opt    ,    but    raise    Invalid_argument
1055       "bool_of_string" instead of returning None .
1056
1057
1058
1059       val string_of_int : int -> string
1060
1061       Return the string representation of an integer, in decimal.
1062
1063
1064
1065       val int_of_string_opt : string -> int option
1066
1067       Convert  the given string to an integer.  The string is read in decimal
1068       (by default, or if the string begins with 0u ), in hexadecimal  (if  it
1069       begins  with  0x or 0X ), in octal (if it begins with 0o or 0O ), or in
1070       binary (if it begins with 0b or 0B ).
1071
1072       The 0u prefix reads the input as an unsigned integer in the  range  [0,
1073       2*max_int+1]  .   If  the  input exceeds max_int it is converted to the
1074       signed integer min_int + input - max_int - 1 .
1075
1076       The _ (underscore) character can appear anywhere in the string  and  is
1077       ignored.
1078
1079       Return None if the given string is not a valid representation of an in‐
1080       teger, or if the integer represented exceeds the range of integers rep‐
1081       resentable in type int .
1082
1083
1084       Since 4.05
1085
1086
1087
1088       val int_of_string : string -> int
1089
1090       Same  as  int_of_string_opt , but raise Failure "int_of_string" instead
1091       of returning None .
1092
1093
1094
1095       val string_of_float : float -> string
1096
1097       Return a string representation of a floating-point number.
1098
1099       This conversion can involve a loss of precision.  For  greater  control
1100       over the manner in which the number is printed, see Printf .
1101
1102
1103
1104       val float_of_string_opt : string -> float option
1105
1106       Convert the given string to a float.  The string is read in decimal (by
1107       default) or in hexadecimal (marked by 0x or 0X ).
1108
1109       The format of decimal floating-point numbers is [-] dd.ddd (e|E)  [+|-]
1110       dd , where d stands for a decimal digit.
1111
1112       The  format  of hexadecimal floating-point numbers is [-] 0(x|X) hh.hhh
1113       (p|P) [+|-] dd , where h stands for an hexadecimal digit and  d  for  a
1114       decimal digit.
1115
1116       In both cases, at least one of the integer and fractional parts must be
1117       given; the exponent part is optional.
1118
1119       The _ (underscore) character can appear anywhere in the string  and  is
1120       ignored.
1121
1122       Depending  on  the execution platforms, other representations of float‐
1123       ing-point numbers can be accepted, but should not be relied upon.
1124
1125       Return None if the given string is not  a  valid  representation  of  a
1126       float.
1127
1128
1129       Since 4.05
1130
1131
1132
1133       val float_of_string : string -> float
1134
1135       Same  as  float_of_string_opt , but raise Failure "float_of_string" in‐
1136       stead of returning None .
1137
1138
1139
1140
1141   Pair operations
1142       val fst : 'a * 'b -> 'a
1143
1144       Return the first component of a pair.
1145
1146
1147
1148       val snd : 'a * 'b -> 'b
1149
1150       Return the second component of a pair.
1151
1152
1153
1154
1155   List operations
1156       More list operations are provided in module List .
1157
1158       val (@) : 'a list -> 'a list -> 'a list
1159
1160       List concatenation.  Not tail-recursive (length of the first argument).
1161       Right-associative operator, see Ocaml_operators for more information.
1162
1163
1164
1165
1166   Input/output
1167       Note:  all  input/output  functions can raise Sys_error when the system
1168       calls they invoke fail.
1169
1170       type in_channel
1171
1172
1173       The type of input channel.
1174
1175
1176       type out_channel
1177
1178
1179       The type of output channel.
1180
1181
1182
1183       val stdin : in_channel
1184
1185       The standard input for the process.
1186
1187
1188
1189       val stdout : out_channel
1190
1191       The standard output for the process.
1192
1193
1194
1195       val stderr : out_channel
1196
1197       The standard error output for the process.
1198
1199
1200
1201
1202   Output functions on standard output
1203       val print_char : char -> unit
1204
1205       Print a character on standard output.
1206
1207
1208
1209       val print_string : string -> unit
1210
1211       Print a string on standard output.
1212
1213
1214
1215       val print_bytes : bytes -> unit
1216
1217       Print a byte sequence on standard output.
1218
1219
1220       Since 4.02.0
1221
1222
1223
1224       val print_int : int -> unit
1225
1226       Print an integer, in decimal, on standard output.
1227
1228
1229
1230       val print_float : float -> unit
1231
1232       Print a floating-point number, in decimal, on standard output.
1233
1234       The conversion of the number to a string uses string_of_float  and  can
1235       involve a loss of precision.
1236
1237
1238
1239       val print_endline : string -> unit
1240
1241       Print a string, followed by a newline character, on standard output and
1242       flush standard output.
1243
1244
1245
1246       val print_newline : unit -> unit
1247
1248       Print a newline character on standard output, and flush  standard  out‐
1249       put. This can be used to simulate line buffering of standard output.
1250
1251
1252
1253
1254   Output functions on standard error
1255       val prerr_char : char -> unit
1256
1257       Print a character on standard error.
1258
1259
1260
1261       val prerr_string : string -> unit
1262
1263       Print a string on standard error.
1264
1265
1266
1267       val prerr_bytes : bytes -> unit
1268
1269       Print a byte sequence on standard error.
1270
1271
1272       Since 4.02.0
1273
1274
1275
1276       val prerr_int : int -> unit
1277
1278       Print an integer, in decimal, on standard error.
1279
1280
1281
1282       val prerr_float : float -> unit
1283
1284       Print a floating-point number, in decimal, on standard error.
1285
1286       The  conversion  of the number to a string uses string_of_float and can
1287       involve a loss of precision.
1288
1289
1290
1291       val prerr_endline : string -> unit
1292
1293       Print a string, followed by a newline character on standard  error  and
1294       flush standard error.
1295
1296
1297
1298       val prerr_newline : unit -> unit
1299
1300       Print a newline character on standard error, and flush standard error.
1301
1302
1303
1304
1305   Input functions on standard input
1306       val read_line : unit -> string
1307
1308       Flush standard output, then read characters from standard input until a
1309       newline character is encountered.
1310
1311       Return the string of all characters read, without the newline character
1312       at the end.
1313
1314
1315       Raises  End_of_file  if the end of the file is reached at the beginning
1316       of line.
1317
1318
1319
1320       val read_int_opt : unit -> int option
1321
1322       Flush standard output, then read one line from standard input and  con‐
1323       vert it to an integer.
1324
1325       Return  None if the line read is not a valid representation of an inte‐
1326       ger.
1327
1328
1329       Since 4.05
1330
1331
1332
1333       val read_int : unit -> int
1334
1335       Same as read_int_opt , but raise Failure "int_of_string" instead of re‐
1336       turning None .
1337
1338
1339
1340       val read_float_opt : unit -> float option
1341
1342       Flush  standard output, then read one line from standard input and con‐
1343       vert it to a floating-point number.
1344
1345       Return None if the line read is not a valid representation of a  float‐
1346       ing-point number.
1347
1348
1349       Since 4.05.0
1350
1351
1352
1353       val read_float : unit -> float
1354
1355       Same as read_float_opt , but raise Failure "float_of_string" instead of
1356       returning None .
1357
1358
1359
1360
1361   General output functions
1362       type open_flag =
1363        | Open_rdonly  (* open for reading.
1364        *)
1365        | Open_wronly  (* open for writing.
1366        *)
1367        | Open_append  (* open for appending: always write at end of file.
1368        *)
1369        | Open_creat  (* create the file if it does not exist.
1370        *)
1371        | Open_trunc  (* empty the file if it already exists.
1372        *)
1373        | Open_excl  (* fail if Open_creat and the file already exists.
1374        *)
1375        | Open_binary  (* open in binary mode (no conversion).
1376        *)
1377        | Open_text  (* open in text mode (may perform conversions).
1378        *)
1379        | Open_nonblock  (* open in non-blocking mode.
1380        *)
1381
1382
1383       Opening modes for open_out_gen and open_in_gen .
1384
1385
1386
1387       val open_out : string -> out_channel
1388
1389       Open the named file for writing, and return a  new  output  channel  on
1390       that  file,  positioned at the beginning of the file. The file is trun‐
1391       cated to zero length if it already exists. It is created if it does not
1392       already exists.
1393
1394
1395
1396       val open_out_bin : string -> out_channel
1397
1398       Same  as  open_out  , but the file is opened in binary mode, so that no
1399       translation takes place during writes. On operating systems that do not
1400       distinguish  between  text  mode and binary mode, this function behaves
1401       like open_out .
1402
1403
1404
1405       val open_out_gen : open_flag list -> int -> string -> out_channel
1406
1407
1408       open_out_gen mode perm filename opens the named file  for  writing,  as
1409       described  above.  The  extra argument mode specifies the opening mode.
1410       The extra argument perm specifies the file  permissions,  in  case  the
1411       file  must  be created.  open_out and open_out_bin are special cases of
1412       this function.
1413
1414
1415
1416       val flush : out_channel -> unit
1417
1418       Flush the buffer associated with the given output  channel,  performing
1419       all pending writes on that channel.  Interactive programs must be care‐
1420       ful about flushing standard output and  standard  error  at  the  right
1421       time.
1422
1423
1424
1425       val flush_all : unit -> unit
1426
1427       Flush all open output channels; ignore errors.
1428
1429
1430
1431       val output_char : out_channel -> char -> unit
1432
1433       Write the character on the given output channel.
1434
1435
1436
1437       val output_string : out_channel -> string -> unit
1438
1439       Write the string on the given output channel.
1440
1441
1442
1443       val output_bytes : out_channel -> bytes -> unit
1444
1445       Write the byte sequence on the given output channel.
1446
1447
1448       Since 4.02.0
1449
1450
1451
1452       val output : out_channel -> bytes -> int -> int -> unit
1453
1454
1455       output  oc  buf  pos len writes len characters from byte sequence buf ,
1456       starting at offset pos , to the given output channel oc .
1457
1458
1459       Raises Invalid_argument if pos and len do not designate a  valid  range
1460       of buf .
1461
1462
1463
1464       val output_substring : out_channel -> string -> int -> int -> unit
1465
1466       Same  as  output  but  take  a string as argument instead of a byte se‐
1467       quence.
1468
1469
1470       Since 4.02.0
1471
1472
1473
1474       val output_byte : out_channel -> int -> unit
1475
1476       Write one 8-bit integer (as the single character with that code) on the
1477       given output channel. The given integer is taken modulo 256.
1478
1479
1480
1481       val output_binary_int : out_channel -> int -> unit
1482
1483       Write  one  integer in binary format (4 bytes, big-endian) on the given
1484       output channel.  The given integer is taken modulo 2^32.  The only  re‐
1485       liable  way  to  read it back is through the input_binary_int function.
1486       The format is compatible across all machines for  a  given  version  of
1487       OCaml.
1488
1489
1490
1491       val output_value : out_channel -> 'a -> unit
1492
1493       Write  the  representation of a structured value of any type to a chan‐
1494       nel. Circularities and sharing inside the value are detected  and  pre‐
1495       served.  The object can be read back, by the function input_value . See
1496       the description of module Marshal for more  information.   output_value
1497       is equivalent to Marshal.to_channel with an empty list of flags.
1498
1499
1500
1501       val seek_out : out_channel -> int -> unit
1502
1503
1504       seek_out  chan pos sets the current writing position to pos for channel
1505       chan . This works only for regular files. On files of other kinds (such
1506       as terminals, pipes and sockets), the behavior is unspecified.
1507
1508
1509
1510       val pos_out : out_channel -> int
1511
1512       Return  the  current  writing position for the given channel.  Does not
1513       work on channels opened with the Open_append flag (returns  unspecified
1514       results).   For  files  opened in text mode under Windows, the returned
1515       position is approximate (owing to end-of-line conversion); in  particu‐
1516       lar, saving the current position with pos_out , then going back to this
1517       position using seek_out will not work.  For this programming  idiom  to
1518       work reliably and portably, the file must be opened in binary mode.
1519
1520
1521
1522       val out_channel_length : out_channel -> int
1523
1524       Return the size (number of characters) of the regular file on which the
1525       given channel is opened.  If the channel is opened on a  file  that  is
1526       not a regular file, the result is meaningless.
1527
1528
1529
1530       val close_out : out_channel -> unit
1531
1532       Close  the given channel, flushing all buffered write operations.  Out‐
1533       put functions raise a Sys_error exception when they are  applied  to  a
1534       closed  output  channel,  except close_out and flush , which do nothing
1535       when applied to an already closed channel.   Note  that  close_out  may
1536       raise  Sys_error if the operating system signals an error when flushing
1537       or closing.
1538
1539
1540
1541       val close_out_noerr : out_channel -> unit
1542
1543       Same as close_out , but ignore all errors.
1544
1545
1546
1547       val set_binary_mode_out : out_channel -> bool -> unit
1548
1549
1550       set_binary_mode_out oc true sets the channel  oc  to  binary  mode:  no
1551       translations  take  place  during output.  set_binary_mode_out oc false
1552       sets the channel oc to text mode: depending on  the  operating  system,
1553       some  translations  may  take place during output.  For instance, under
1554       Windows, end-of-lines will be translated from \n to \r\n .  This  func‐
1555       tion  has no effect under operating systems that do not distinguish be‐
1556       tween text mode and binary mode.
1557
1558
1559
1560
1561   General input functions
1562       val open_in : string -> in_channel
1563
1564       Open the named file for reading, and return a new input channel on that
1565       file, positioned at the beginning of the file.
1566
1567
1568
1569       val open_in_bin : string -> in_channel
1570
1571       Same  as  open_in  ,  but the file is opened in binary mode, so that no
1572       translation takes place during reads. On operating systems that do  not
1573       distinguish  between  text  mode and binary mode, this function behaves
1574       like open_in .
1575
1576
1577
1578       val open_in_gen : open_flag list -> int -> string -> in_channel
1579
1580
1581       open_in_gen mode perm filename opens the named file for reading, as de‐
1582       scribed  above.  The  extra arguments mode and perm specify the opening
1583       mode and file permissions.  open_in and open_in_bin are  special  cases
1584       of this function.
1585
1586
1587
1588       val input_char : in_channel -> char
1589
1590       Read one character from the given input channel.
1591
1592
1593       Raises End_of_file if there are no more characters to read.
1594
1595
1596
1597       val input_line : in_channel -> string
1598
1599       Read characters from the given input channel, until a newline character
1600       is encountered. Return the string of all characters read,  without  the
1601       newline character at the end.
1602
1603
1604       Raises  End_of_file  if the end of the file is reached at the beginning
1605       of line.
1606
1607
1608
1609       val input : in_channel -> bytes -> int -> int -> int
1610
1611
1612       input ic buf pos len reads up to len characters from the given  channel
1613       ic  ,  storing them in byte sequence buf , starting at character number
1614       pos .  It returns the actual number of characters read, between  0  and
1615       len  (inclusive).   A  return value of 0 means that the end of file was
1616       reached.  A return value between 0 and len exclusive means that not all
1617       requested  len  characters were read, either because no more characters
1618       were available at that time, or because  the  implementation  found  it
1619       convenient to do a partial read; input must be called again to read the
1620       remaining characters, if desired.  (See also really_input  for  reading
1621       exactly  len characters.)  Exception Invalid_argument "input" is raised
1622       if pos and len do not designate a valid range of buf .
1623
1624
1625
1626       val really_input : in_channel -> bytes -> int -> int -> unit
1627
1628
1629       really_input ic buf pos len reads len  characters  from  channel  ic  ,
1630       storing them in byte sequence buf , starting at character number pos .
1631
1632
1633       Raises  End_of_file if the end of file is reached before len characters
1634       have been read.
1635
1636
1637       Raises Invalid_argument if pos and len do not designate a  valid  range
1638       of buf .
1639
1640
1641
1642       val really_input_string : in_channel -> int -> string
1643
1644
1645       really_input_string ic len reads len characters from channel ic and re‐
1646       turns them in a new string.
1647
1648
1649       Since 4.02.0
1650
1651
1652       Raises End_of_file if the end of file is reached before len  characters
1653       have been read.
1654
1655
1656
1657       val input_byte : in_channel -> int
1658
1659       Same  as  input_char  ,  but  return the 8-bit integer representing the
1660       character.
1661
1662
1663       Raises End_of_file if the end of file was reached.
1664
1665
1666
1667       val input_binary_int : in_channel -> int
1668
1669       Read an integer encoded in binary format (4 bytes, big-endian) from the
1670       given input channel. See output_binary_int .
1671
1672
1673       Raises End_of_file if the end of file was reached while reading the in‐
1674       teger.
1675
1676
1677
1678       val input_value : in_channel -> 'a
1679
1680       Read the representation of a structured  value,  as  produced  by  out‐
1681       put_value , and return the corresponding value.  This function is iden‐
1682       tical to Marshal.from_channel ; see the description of  module  Marshal
1683       for more information, in particular concerning the lack of type safety.
1684
1685
1686
1687       val seek_in : in_channel -> int -> unit
1688
1689
1690       seek_in  chan  pos sets the current reading position to pos for channel
1691       chan . This works only for regular files. On files of other kinds,  the
1692       behavior is unspecified.
1693
1694
1695
1696       val pos_in : in_channel -> int
1697
1698       Return  the  current reading position for the given channel.  For files
1699       opened in text mode under Windows, the returned position is approximate
1700       (owing  to  end-of-line  conversion); in particular, saving the current
1701       position with pos_in , then going back to this position  using  seek_in
1702       will  not  work.   For  this  programming  idiom  to  work reliably and
1703       portably, the file must be opened in binary mode.
1704
1705
1706
1707       val in_channel_length : in_channel -> int
1708
1709       Return the size (number of characters) of the regular file on which the
1710       given  channel  is  opened.  If the channel is opened on a file that is
1711       not a regular file, the result is meaningless.  The returned size  does
1712       not  take  into  account  the end-of-line translations that can be per‐
1713       formed when reading from a channel opened in text mode.
1714
1715
1716
1717       val close_in : in_channel -> unit
1718
1719       Close the given channel.  Input functions raise a  Sys_error  exception
1720       when  they  are  applied  to  a closed input channel, except close_in ,
1721       which does nothing when applied to an already closed channel.
1722
1723
1724
1725       val close_in_noerr : in_channel -> unit
1726
1727       Same as close_in , but ignore all errors.
1728
1729
1730
1731       val set_binary_mode_in : in_channel -> bool -> unit
1732
1733
1734       set_binary_mode_in ic true sets the  channel  ic  to  binary  mode:  no
1735       translations  take  place  during  input.  set_binary_mode_out ic false
1736       sets the channel ic to text mode: depending on  the  operating  system,
1737       some  translations  may  take  place during input.  For instance, under
1738       Windows, end-of-lines will be translated from \r\n to \n .  This  func‐
1739       tion  has no effect under operating systems that do not distinguish be‐
1740       tween text mode and binary mode.
1741
1742
1743
1744
1745   Operations on large files
1746       module LargeFile : sig end
1747
1748
1749       Operations on large files.  This sub-module provides 64-bit variants of
1750       the  channel  functions  that manipulate file positions and file sizes.
1751       By representing positions and sizes by 64-bit integers  (type  int64  )
1752       instead  of regular integers (type int ), these alternate functions al‐
1753       low operating on files whose sizes are greater than max_int .
1754
1755
1756
1757
1758   References
1759       type 'a ref = {
1760
1761       mutable contents : 'a ;
1762        }
1763
1764
1765       The type of references (mutable indirection cells) containing  a  value
1766       of type 'a .
1767
1768
1769
1770       val ref : 'a -> 'a ref
1771
1772       Return a fresh reference containing the given value.
1773
1774
1775
1776       val (!)  : 'a ref -> 'a
1777
1778
1779       !r  returns  the current contents of reference r .  Equivalent to fun r
1780       -> r.contents .  Unary operator, see Ocaml_operators for more  informa‐
1781       tion.
1782
1783
1784
1785       val (:=) : 'a ref -> 'a -> unit
1786
1787
1788       r := a stores the value of a in reference r .  Equivalent to fun r v ->
1789       r.contents <- v .  Right-associative operator, see Ocaml_operators  for
1790       more information.
1791
1792
1793
1794       val incr : int ref -> unit
1795
1796       Increment  the integer contained in the given reference.  Equivalent to
1797       fun r -> r := succ !r .
1798
1799
1800
1801       val decr : int ref -> unit
1802
1803       Decrement the integer contained in the given reference.  Equivalent  to
1804       fun r -> r := pred !r .
1805
1806
1807
1808
1809   Result type
1810       type ('a, 'b) result =
1811        | Ok of 'a
1812        | Error of 'b
1813
1814
1815       Since 4.03.0
1816
1817
1818
1819
1820   Operations on format strings
1821       Format  strings  are character strings with special lexical conventions
1822       that defines the functionality  of  formatted  input/output  functions.
1823       Format  strings  are  used  to read data with formatted input functions
1824       from module Scanf and to print data  with  formatted  output  functions
1825       from modules Printf and Format .
1826
1827       Format strings are made of three kinds of entities:
1828
1829       -conversions  specifications,  introduced  by the special character '%'
1830       followed by one or more characters specifying what kind of argument  to
1831       read or print,
1832
1833       -formatting  indications,  introduced by the special character '@' fol‐
1834       lowed by one or more characters specifying how to read or print the ar‐
1835       gument,
1836
1837       -plain  characters  that are regular characters with usual lexical con‐
1838       ventions. Plain characters specify string literals to be  read  in  the
1839       input or printed in the output.
1840
1841       There  is  an  additional lexical rule to escape the special characters
1842       '%' and '@' in format strings: if a special  character  follows  a  '%'
1843       character,  it is treated as a plain character. In other words, "%%" is
1844       considered as a plain '%' and "%@" as a plain '@' .
1845
1846       For more information about conversion specifications and formatting in‐
1847       dications  available,  read the documentation of modules Scanf , Printf
1848       and Format .
1849
1850       Format strings have a general and highly polymorphic type ('a, 'b,  'c,
1851       'd, 'e, 'f) format6 .  The two simplified types, format and format4 be‐
1852       low are included for backward compatibility with  earlier  releases  of
1853       OCaml.
1854
1855       The meaning of format string type parameters is as follows:
1856
1857
1858       -  'a  is the type of the parameters of the format for formatted output
1859       functions ( printf -style functions); 'a is the type of the values read
1860       by the format for formatted input functions ( scanf -style functions).
1861
1862
1863       -  'b is the type of input source for formatted input functions and the
1864       type of output target  for  formatted  output  functions.   For  printf
1865       -style functions from module Printf , 'b is typically out_channel ; for
1866       printf -style functions from module  Format  ,  'b  is  typically  For‐
1867       mat.formatter  ;  for  scanf -style functions from module Scanf , 'b is
1868       typically Scanf.Scanning.in_channel .
1869
1870       Type argument 'b is also the type of the first argument given to user's
1871       defined  printing  functions  for %a and %t conversions, and user's de‐
1872       fined reading functions for %r conversion.
1873
1874
1875       - 'c is the type of the result of the %a and %t printing functions, and
1876       also  the  type  of  the  argument transmitted to the first argument of
1877       kprintf -style functions or to the kscanf -style functions.
1878
1879
1880       - 'd is the type of parameters for the scanf -style functions.
1881
1882
1883       - 'e is the type of the receiver function for the  scanf  -style  func‐
1884       tions.
1885
1886
1887       -  'f is the final result type of a formatted input/output function in‐
1888       vocation: for the printf -style functions, it is typically unit  ;  for
1889       the  scanf -style functions, it is typically the result type of the re‐
1890       ceiver function.
1891
1892
1893       type ('a, 'b, 'c, 'd, 'e, 'f) format6 = ('a, 'b, 'c, 'd, 'e,  'f)  Cam‐
1894       linternalFormatBasics.format6
1895
1896
1897
1898
1899       type ('a, 'b, 'c, 'd) format4 = ('a, 'b, 'c, 'c, 'c, 'd) format6
1900
1901
1902
1903
1904       type ('a, 'b, 'c) format = ('a, 'b, 'c, 'c) format4
1905
1906
1907
1908
1909
1910       val string_of_format : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> string
1911
1912       Converts a format string into a string.
1913
1914
1915
1916       val format_of_string : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> ('a, 'b, 'c,
1917       'd, 'e, 'f) format6
1918
1919
1920       format_of_string s returns a format string read from the string literal
1921       s  .   Note: format_of_string can not convert a string argument that is
1922       not a literal. If you need this functionality,  use  the  more  general
1923       Scanf.format_from_string function.
1924
1925
1926
1927       val (^^) : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> ('f, 'b, 'c, 'e, 'g, 'h)
1928       format6 -> ('a, 'b, 'c, 'd, 'g, 'h) format6
1929
1930
1931       f1 ^^ f2 catenates format strings f1 and f2 . The result  is  a  format
1932       string  that behaves as the concatenation of format strings f1 and f2 :
1933       in case of formatted output, it accepts arguments from f1 , then  argu‐
1934       ments  from f2 ; in case of formatted input, it returns results from f1
1935       , then results from f2 .  Right-associative operator, see  Ocaml_opera‐
1936       tors for more information.
1937
1938
1939
1940
1941   Program termination
1942       val exit : int -> 'a
1943
1944       Terminate the process, returning the given status code to the operating
1945       system: usually 0 to indicate no errors, and a small  positive  integer
1946       to  indicate  failure.  All  open  output  channels  are  flushed  with
1947       flush_all .  The callbacks registered with  Domain.at_exit  are  called
1948       followed by those registered with at_exit .
1949
1950       An  implicit  exit  0  is performed each time a program terminates nor‐
1951       mally.  An implicit exit 2 is performed if the program terminates early
1952       because of an uncaught exception.
1953
1954
1955
1956       val at_exit : (unit -> unit) -> unit
1957
1958       Register  the  given function to be called at program termination time.
1959       The functions registered with at_exit will be called when  the  program
1960       does any of the following:
1961
1962       -executes exit
1963
1964
1965       -terminates, either normally or because of an uncaught exception
1966
1967       -executes  the  C function caml_shutdown .  The functions are called in
1968       'last in, first out' order:  the  function  most  recently  added  with
1969       at_exit is called first.
1970
1971
1972
1973
1974
1975   Standard library modules
1976       module Arg : (module Stdlib__Arg)
1977
1978
1979
1980
1981       module Array : (module Stdlib__Array)
1982
1983
1984
1985
1986       module ArrayLabels : (module Stdlib__ArrayLabels)
1987
1988
1989
1990
1991       module Atomic : (module Stdlib__Atomic)
1992
1993
1994
1995
1996       module Bigarray : (module Stdlib__Bigarray)
1997
1998
1999
2000
2001       module Bool : (module Stdlib__Bool)
2002
2003
2004
2005
2006       module Buffer : (module Stdlib__Buffer)
2007
2008
2009
2010
2011       module Bytes : (module Stdlib__Bytes)
2012
2013
2014
2015
2016       module BytesLabels : (module Stdlib__BytesLabels)
2017
2018
2019
2020
2021       module Callback : (module Stdlib__Callback)
2022
2023
2024
2025
2026       module Char : (module Stdlib__Char)
2027
2028
2029
2030
2031       module Complex : (module Stdlib__Complex)
2032
2033
2034
2035
2036       module Condition : (module Stdlib__Condition)
2037
2038
2039
2040
2041       module Digest : (module Stdlib__Digest)
2042
2043
2044
2045
2046       module Domain : (module Stdlib__Domain)
2047
2048
2049       Alert  unstable.   The Domain interface may change in incompatible ways
2050       in the future.
2051
2052
2053       module Effect : (module Stdlib__Effect)
2054
2055
2056       Alert unstable.  The Effect interface may change in  incompatible  ways
2057       in the future.
2058
2059
2060       module Either : (module Stdlib__Either)
2061
2062
2063
2064
2065       module Ephemeron : (module Stdlib__Ephemeron)
2066
2067
2068
2069
2070       module Filename : (module Stdlib__Filename)
2071
2072
2073
2074
2075       module Float : (module Stdlib__Float)
2076
2077
2078
2079
2080       module Format : (module Stdlib__Format)
2081
2082
2083
2084
2085       module Fun : (module Stdlib__Fun)
2086
2087
2088
2089
2090       module Gc : (module Stdlib__Gc)
2091
2092
2093
2094
2095       module Hashtbl : (module Stdlib__Hashtbl)
2096
2097
2098
2099
2100       module In_channel : (module Stdlib__In_channel)
2101
2102
2103
2104
2105       module Int : (module Stdlib__Int)
2106
2107
2108
2109
2110       module Int32 : (module Stdlib__Int32)
2111
2112
2113
2114
2115       module Int64 : (module Stdlib__Int64)
2116
2117
2118
2119
2120       module Lazy : (module Stdlib__Lazy)
2121
2122
2123
2124
2125       module Lexing : (module Stdlib__Lexing)
2126
2127
2128
2129
2130       module List : (module Stdlib__List)
2131
2132
2133
2134
2135       module ListLabels : (module Stdlib__ListLabels)
2136
2137
2138
2139
2140       module Map : (module Stdlib__Map)
2141
2142
2143
2144
2145       module Marshal : (module Stdlib__Marshal)
2146
2147
2148
2149
2150       module MoreLabels : (module Stdlib__MoreLabels)
2151
2152
2153
2154
2155       module Mutex : (module Stdlib__Mutex)
2156
2157
2158
2159
2160       module Nativeint : (module Stdlib__Nativeint)
2161
2162
2163
2164
2165       module Obj : (module Stdlib__Obj)
2166
2167
2168
2169
2170       module Oo : (module Stdlib__Oo)
2171
2172
2173
2174
2175       module Option : (module Stdlib__Option)
2176
2177
2178
2179
2180       module Out_channel : (module Stdlib__Out_channel)
2181
2182
2183
2184
2185       module Parsing : (module Stdlib__Parsing)
2186
2187
2188
2189
2190       module Printexc : (module Stdlib__Printexc)
2191
2192
2193
2194
2195       module Printf : (module Stdlib__Printf)
2196
2197
2198
2199
2200       module Queue : (module Stdlib__Queue)
2201
2202
2203
2204
2205       module Random : (module Stdlib__Random)
2206
2207
2208
2209
2210       module Result : (module Stdlib__Result)
2211
2212
2213
2214
2215       module Scanf : (module Stdlib__Scanf)
2216
2217
2218
2219
2220       module Semaphore : (module Stdlib__Semaphore)
2221
2222
2223
2224
2225       module Seq : (module Stdlib__Seq)
2226
2227
2228
2229
2230       module Set : (module Stdlib__Set)
2231
2232
2233
2234
2235       module Stack : (module Stdlib__Stack)
2236
2237
2238
2239
2240       module StdLabels : (module Stdlib__StdLabels)
2241
2242
2243
2244
2245       module String : (module Stdlib__String)
2246
2247
2248
2249
2250       module StringLabels : (module Stdlib__StringLabels)
2251
2252
2253
2254
2255       module Sys : (module Stdlib__Sys)
2256
2257
2258
2259
2260       module Uchar : (module Stdlib__Uchar)
2261
2262
2263
2264
2265       module Unit : (module Stdlib__Unit)
2266
2267
2268
2269
2270       module Weak : (module Stdlib__Weak)
2271
2272
2273
2274
2275
2276
2277
2278OCamldoc                          2023-07-20                         Stdlib(3)
Impressum