File: stdcompat__pervasives.ml.in

package info (click to toggle)
ocaml-stdcompat 19-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,516 kB
  • sloc: ml: 27,806; sh: 875; makefile: 246
file content (114 lines) | stat: -rw-r--r-- 2,137 bytes parent folder | download
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
@BEGIN_FROM_4_07_0@
include Stdlib
@END_FROM_4_07_0@
@BEGIN_BEFORE_4_07_0@
include Pervasives
@END_BEFORE_4_07_0@

@BEGIN_BEFORE_4_03_0@
type ('a, 'b) result
  = ('a, 'b) Stdcompat__init.result
  = Ok of 'a | Error of 'b
@END_BEFORE_4_03_0@

@BEGIN_BEFORE_4_02_0@
external raise_notrace : exn -> 'a = "%raise"
@END_BEFORE_4_02_0@

@BEGIN_BEFORE_4_05_0@
let bool_of_string_opt s =
  Stdcompat__tools.option_invalid bool_of_string s

let int_of_string_opt s =
  Stdcompat__tools.option_fail int_of_string s

let float_of_string_opt s =
  Stdcompat__tools.option_fail float_of_string s

let read_int_opt () =
  Stdcompat__tools.option_fail read_int ()

let read_float_opt () =
  Stdcompat__tools.option_fail read_float ()
@END_BEFORE_4_05_0@

@BEGIN_BEFORE_4_02_0@
let print_bytes = print_string

let prerr_bytes = prerr_string

let output_bytes = output_string

let output_substring = output

let really_input_string channel len =
  let s = String.create len in
  really_input channel s 0 len;
  s

type ('a, 'b, 'c, 'd, 'e, 'f) format6 =
  ('a, 'b, 'c, 'd, 'e, 'f) Stdcompat__init.format6

@BEGIN_BEFORE_3_10_0@
type ('a, 'b, 'c, 'd) format4 =
  ('a, 'b, 'c, 'c, 'c, 'd) format6
@END_BEFORE_3_10_0@

let __LOC__ = ""

let __MODULE__ = ""

let __POS__ = ("", 0, 0, 0)

let __LOC_OF__ x = (__LOC__, x)

let __LINE__ = 0

let __FILE__ = ""

let __LINE_OF__ x = (0, x)

let __POS_OF__ x = (__POS__, x)
@END_BEFORE_4_02_0@

@BEGIN_BEFORE_4_01_0@
let ( |> ) x f = f x

let ( @@ ) f x = f x
@END_BEFORE_4_01_0@

@BEGIN_BEFORE_4_00_0@
let hypot x y =
  sqrt (x *. x +. y *. y)

let copysign x y =
  if (x >= 0.) = (y >= 0.) then
    x
  else
    -. x
@END_BEFORE_4_00_0@

@BEGIN_BEFORE_3_12_0@
external (~+) : int -> int = "%identity"

external (~+.) : float -> float = "%identity"

(* These emulations of expm1() and log1p() are due to William Kahan.
   See http://www.plunk.org/~hatch/rightway.php *)

let expm1 x =
  let u = exp x in
  if u = 1. then
    x
  else if u -. 1. = -1. then
    -1.
  else
    (u -. 1.) *. x /. log u

let log1p x =
  let u = 1. +. x in
  if u = 1. then
    x
  else
    log u *. x /. (u -. 1.)
@END_BEFORE_3_12_0@