Skip to content

Commit 291cddb

Browse files
v0.18~preview.130.26+1192
1 parent c76d3cf commit 291cddb

File tree

135 files changed

+5710
-6681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+5710
-6681
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2008--2024 Jane Street Group, LLC <[email protected]>
3+
Copyright (c) 2008--2025 Jane Street Group, LLC <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

ansi_kernel/src/ansi_kernel.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ module Color : sig
3131
end
3232

3333
module Attr : sig
34-
(** Styling attributes: these provide most of the ANSI display attributes,
35-
but not directly `Reset, `Blink and `Hidden, so as to explicitly
36-
discourage their use in general code. *)
34+
(** Styling attributes: these provide most of the ANSI display attributes, but not
35+
directly `Reset, `Blink and `Hidden, so as to explicitly discourage their use in
36+
general code. *)
3737
type t =
3838
[ `Bright
3939
| `Dim

ansi_kernel/src/color_256.mli

Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,89 @@
1-
(** Support for 256-color handling on terminals/consoles. Note that the
2-
functions [of_rgb6_exn] and [of_rgb6] return values within the 6x6x6
3-
color-cube space, even though equivalent duplicates exist in the first 16
4-
and last 24 colors (a "best-fit-equivalent" function could be added some
5-
day, if there ever becomes a requirement for it -- see note 2 below).
1+
(** Support for 256-color handling on terminals/consoles. Note that the functions
2+
[of_rgb6_exn] and [of_rgb6] return values within the 6x6x6 color-cube space, even
3+
though equivalent duplicates exist in the first 16 and last 24 colors (a
4+
"best-fit-equivalent" function could be added some day, if there ever becomes a
5+
requirement for it -- see note 2 below).
66
7-
NOTE 1: the color-cube is not linear in terms of RGB levels, but is
8-
"shifted" towards brighter values (as opposed to a logarithmic or other
9-
mapping). Visually, the "rgb6" values 0 to 5 (used in [of_rgb6_exn] and
10-
encoded in the 256-color palette values) map into RGB levels as follows:
7+
NOTE 1: the color-cube is not linear in terms of RGB levels, but is "shifted" towards
8+
brighter values (as opposed to a logarithmic or other mapping). Visually, the "rgb6"
9+
values 0 to 5 (used in [of_rgb6_exn] and encoded in the 256-color palette values) map
10+
into RGB levels as follows:
1111
1212
{v
1313
Cube-val: 0 1 2 3 4 5
1414
v +-----------+----+----+----+----+
1515
RGB: 0 95 135 175 215 255
1616
v}
1717
18-
The floating-point values used in [of_rgb] are {e not} weighted in the same
19-
way, but are rounded to the nearest cube-value -- a value of 0.5 (50% or
20-
127.5/255) would result in a color-cube value of 2, for example. Any level
21-
less than 0.187 (approx.) maps to 0 (black) and greater than 0.921 to 5
22-
(white).
18+
The floating-point values used in [of_rgb] are {e not} weighted in the same way, but
19+
are rounded to the nearest cube-value -- a value of 0.5 (50% or 127.5/255) would
20+
result in a color-cube value of 2, for example. Any level less than 0.187 (approx.)
21+
maps to 0 (black) and greater than 0.921 to 5 (white).
2322
24-
NOTE 2: is is {e not} recommended to use the 256-color palette for
25-
representing the 16 (8 * 2) 'primary' colors. The standard [`Black],
26-
[`Blue], etc. attributes are recommended for these.
27-
*)
23+
NOTE 2: is is {e not} recommended to use the 256-color palette for representing the 16
24+
(8 * 2) 'primary' colors. The standard [`Black], [`Blue], etc. attributes are
25+
recommended for these. *)
2826

2927
type t [@@deriving sexp_of, compare, hash, equal]
3028

3129
val to_int : t -> int
3230
val of_int_exn : int -> t
3331

34-
(** Takes an RGB triple with values in the range [0,5] (inclusive) and returns
35-
the appropriate 256-color palette value. Will throw an exception if any of
36-
the inputs are out-of-range. Note that the input values are weighted as
37-
described above. *)
32+
(** Takes an RGB triple with values in the range [0,5] (inclusive) and returns the
33+
appropriate 256-color palette value. Will throw an exception if any of the inputs are
34+
out-of-range. Note that the input values are weighted as described above. *)
3835
val of_rgb6_exn : int * int * int -> t
3936

40-
(** Takes an RGB triple with float values in the closed (inclusive) interval
41-
[0,1] and returns the nearest (rounded) 256-color palette value.
42-
Out-of-bound values are clamped to the range. The inputs are {e not}
43-
weighted, unlike [of_rgb6_exn] as described above. *)
37+
(** Takes an RGB triple with float values in the closed (inclusive) interval [0,1] and
38+
returns the nearest (rounded) 256-color palette value. Out-of-bound values are clamped
39+
to the range. The inputs are {e not} weighted, unlike [of_rgb6_exn] as described
40+
above. *)
4441
val of_rgb : float * float * float -> t
4542

46-
(** Takes an RGB triple with integer values in the closed (inclusive) range
47-
[0,255] and returns the nearest (rounded) 256-color palette color-cube
48-
value. Out-of-bound values are clamped to the range. The inputs are
49-
{e not} weighted, unlike [of_rgb6_exn] as described above. *)
43+
(** Takes an RGB triple with integer values in the closed (inclusive) range [0,255] and
44+
returns the nearest (rounded) 256-color palette color-cube value. Out-of-bound values
45+
are clamped to the range. The inputs are {e not} weighted, unlike [of_rgb6_exn] as
46+
described above. *)
5047
val of_rgb_8bit : int * int * int -> t
5148

52-
(** Takes an RGB triple with integer values in the closed (inclusive) range
53-
[0,1000] and returns the nearest (rounded) 256-color palette color-cube
54-
value. Out-of-bound values are clamped to the range. The inputs are {e not}
55-
weighted, unlike [of_rgb6_exn] as described above. *)
49+
(** Takes an RGB triple with integer values in the closed (inclusive) range [0,1000] and
50+
returns the nearest (rounded) 256-color palette color-cube value. Out-of-bound values
51+
are clamped to the range. The inputs are {e not} weighted, unlike [of_rgb6_exn] as
52+
described above. *)
5653
val of_rgb_int1k : int * int * int -> t
5754

58-
(** Takes a grayscale level from [0-23] (inclusive, not-black-to-not-white)
59-
and returns the appropriate 256-color palette value. Will throw an
60-
exception if the input value is out-of-range. *)
55+
(** Takes a grayscale level from [0-23] (inclusive, not-black-to-not-white) and returns
56+
the appropriate 256-color palette value. Will throw an exception if the input value is
57+
out-of-range. *)
6158
val of_gray24_exn : int -> t
6259

63-
(** Takes a color palette value and returns, for color-cube and grayscale
64-
palette values, an approximated [`RGB] triple with each component in the
65-
range [0,1]; for the first 16 values, [`Primary] followed by the specific
66-
palette index is returned, as these are not consistently defined. *)
60+
(** Takes a color palette value and returns, for color-cube and grayscale palette values,
61+
an approximated [`RGB] triple with each component in the range [0,1]; for the first 16
62+
values, [`Primary] followed by the specific palette index is returned, as these are
63+
not consistently defined. *)
6764
val to_rgb : t -> [> `Primary of int | `RGB of float * float * float ]
6865

69-
(** Takes a color palette value and returns a hex-encoded RGB 24-bit triplet,
70-
with a leading '#'. I.e. "#000000" through "#ffffff". The values
71-
returned for the first 16 (primary) colors follow the Windows Console
72-
scheme, as documented here: https://en.wikipedia.org/wiki/ANSI_escape_code .
73-
*)
66+
(** Takes a color palette value and returns a hex-encoded RGB 24-bit triplet, with a
67+
leading '#'. I.e. "#000000" through "#ffffff". The values returned for the first 16
68+
(primary) colors follow the Windows Console scheme, as documented here:
69+
https://en.wikipedia.org/wiki/ANSI_escape_code . *)
7470
val to_rgb_hex24 : t -> string
7571

76-
(** Takes a color palette value and returns an approximate luminance value
77-
in the closed interval [0,1]. *)
72+
(** Takes a color palette value and returns an approximate luminance value in the closed
73+
interval [0,1]. *)
7874
val to_luma : t -> float
7975

80-
(** Takes a color palette value and returns a triple of RGB integers in
81-
the closed interval [0,255]. *)
76+
(** Takes a color palette value and returns a triple of RGB integers in the closed
77+
interval [0,255]. *)
8278
val to_rgb_8bit : t -> int * int * int
8379

84-
(** Takes a color palette value and returns a triple of RGB integers in
85-
the closed interval [0,1000]. *)
80+
(** Takes a color palette value and returns a triple of RGB integers in the closed
81+
interval [0,1000]. *)
8682
val to_rgb_int1k : t -> int * int * int
8783

88-
(** Takes a color palette value and returns a triple of RGB integers in
89-
the closed interval [0,5]. For color-cube palette values, this simply
90-
un-does [of_rgb6_exn]. For others, it will return the closest matching
91-
value in the color-cube. *)
84+
(** Takes a color palette value and returns a triple of RGB integers in the closed
85+
interval [0,5]. For color-cube palette values, this simply un-does [of_rgb6_exn]. For
86+
others, it will return the closest matching value in the color-cube. *)
9287
val to_rgb6 : t -> int * int * int
9388

9489
module Stable : sig

balanced_reducer/src/balanced_reducer.mli

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ type 'a t [@@deriving sexp_of]
99
include Invariant.S1 with type 'a t := 'a t
1010

1111
(** [create_exn ~len ~reduce] creates a balanced reducer of length [len], all of whose
12-
elements are [None]. It raises if [len < 1]. *)
12+
elements are [None]. It raises if [len < 1]. *)
1313
val create_exn
1414
: ?sexp_of_a:('a -> Sexp.t) (** for improved error messages *)
1515
-> unit
1616
-> len:int
1717
-> reduce:('a -> 'a -> 'a)
1818
-> 'a t
1919

20-
(** [set_exn t i a] updates the value at index [i] to [Some a]. It raises if [i] is out
21-
of bounds. *)
20+
(** [set_exn t i a] updates the value at index [i] to [Some a]. It raises if [i] is out of
21+
bounds. *)
2222
val set_exn : 'a t -> int -> 'a -> unit
2323

24-
(** [get_exn t i] gets the value at index [i]. It raises if [i] is out of bounds, or
24+
(** [get_exn t i] gets the value at index [i]. It raises if [i] is out of bounds, or
2525
[set_exn t i] has never been called. *)
2626
val get_exn : 'a t -> int -> 'a
2727

28-
(** [compute_exn t] computes the value of the fold. It raises if any values of the array
28+
(** [compute_exn t] computes the value of the fold. It raises if any values of the array
2929
are [None]. *)
3030
val compute_exn : 'a t -> 'a
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module Test_balanced_reducer = Test_balanced_reducer

binary_packing/src/binary_packing.mli

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
[pos] arguments refer to the location in the buf string.
77
88
We support big- and little-endian ints. Note that for an 8-bit (1-byte) integer, there
9-
is no difference, because endian-ness only changes the order of bytes, not bits.
10-
*)
9+
is no difference, because endian-ness only changes the order of bytes, not bits. *)
1110

1211
open! Core
1312
open! Import
@@ -39,9 +38,7 @@ val pack_unsigned_8 : buf:bytes -> pos:int -> int -> unit
3938
unpack_signed_64_int | 21 ns | 0 ns | M
4039
pack_signed_64_little_endian | 8 ns | 0 ns |
4140
unpack_signed_64_little_endian | 9 ns | 0 ns | M
42-
43-
v}
44-
*)
41+
v} *)
4542
val unpack_signed_16 : byte_order:endian -> buf:bytes -> pos:int -> int
4643

4744
val pack_signed_16 : byte_order:endian -> buf:bytes -> pos:int -> int -> unit
@@ -95,8 +92,8 @@ val pack_float : byte_order:endian -> buf:bytes -> pos:int -> float -> unit
9592
plus the length of the padding equals the fixed length. *)
9693

9794
(** Decode the fixed-length tail-padded string having length [len] from [buf] starting at
98-
[pos]. Return a string containing only the non-padding characters. The default
99-
padding is '\x00'. *)
95+
[pos]. Return a string containing only the non-padding characters. The default padding
96+
is '\x00'. *)
10097
val unpack_tail_padded_fixed_string
10198
: ?padding:char
10299
-> buf:Bytes.t
@@ -106,9 +103,9 @@ val unpack_tail_padded_fixed_string
106103
-> string
107104

108105
(** Encode and pack the given string as a tail padded fixed length string having length
109-
[len]. Place it in [buf] starting at position [pos]. If the length of the string is
106+
[len]. Place it in [buf] starting at position [pos]. If the length of the string is
110107
less then [len] pad it with the padding characters until its length is equal to [len].
111-
If the string is longer than [len] raise [Invalid_argument]. The default padding is
108+
If the string is longer than [len] raise [Invalid_argument]. The default padding is
112109
'\x00'. *)
113110
val pack_tail_padded_fixed_string
114111
: ?padding:char

binary_packing/test-bin/test_binary_packing.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let test byte_order =
5858
string_of_int
5959
; "[pack|unpack]_signed_32"
6060
>:: inverses
61-
(fun n -> Int32.( + ) (Int32.of_int_exn n))
61+
(fun n m -> Int32.( + ) (Int32.of_int_exn n) m)
6262
1
6363
B.pack_signed_32
6464
B.unpack_signed_32
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module Import = Import
2+
module Test_binary_packing = Test_binary_packing

bounded_int_table/src/bounded_int_table.ml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,15 @@ let invariant invariant_key invariant_data t =
7272
with
7373
| exn ->
7474
let sexp_of_key = sexp_of_key t in
75-
failwiths
76-
~here:[%here]
77-
"invariant failed"
78-
(exn, t)
79-
[%sexp_of: exn * (key, _) t_detailed]
75+
failwiths "invariant failed" (exn, t) [%sexp_of: exn * (key, _) t_detailed]
8076
;;
8177

8278
let debug = ref false
8379
let check_invariant t = if !debug then invariant ignore ignore t
8480
let is_empty t = length t = 0
8581

8682
let create ?sexp_of_key ~num_keys ~key_to_int () =
87-
if num_keys < 0
88-
then failwiths ~here:[%here] "num_keys must be nonnegative" num_keys [%sexp_of: int];
83+
if num_keys < 0 then failwiths "num_keys must be nonnegative" num_keys [%sexp_of: int];
8984
let t =
9085
{ num_keys
9186
; sexp_of_key
@@ -163,7 +158,6 @@ let entry_opt t key =
163158
| _ ->
164159
let sexp_of_key = sexp_of_key t in
165160
failwiths
166-
~here:[%here]
167161
"key's index out of range"
168162
(key, index, `Should_be_between_0_and (t.num_keys - 1))
169163
[%sexp_of: key * int * [ `Should_be_between_0_and of int ]]
@@ -181,7 +175,6 @@ let find_exn t key =
181175
| None ->
182176
let sexp_of_key = sexp_of_key t in
183177
failwiths
184-
~here:[%here]
185178
"Bounded_int_table.find_exn got unknown key"
186179
(key, t)
187180
[%sexp_of: key * (key, _) t]
@@ -230,7 +223,6 @@ let add_exn t ~key ~data =
230223
| `Duplicate _ ->
231224
let sexp_of_key = sexp_of_key t in
232225
failwiths
233-
~here:[%here]
234226
"Bounded_int_table.add_exn of key whose index is already present"
235227
(key, t.key_to_int key)
236228
[%sexp_of: key * int]
@@ -250,7 +242,6 @@ let remove t key =
250242
| None ->
251243
let sexp_of_key = sexp_of_key t in
252244
failwiths
253-
~here:[%here]
254245
"Bounded_int_table.remove bug"
255246
(key, last, t)
256247
[%sexp_of: key * int * (key, _) t_detailed]

bounded_int_table/src/bounded_int_table.mli

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
is willing to pay a space cost for the speed.
55
66
[Bounded_int_table] presents a subset of the [Hashtbl] interface. The key type can be
7-
any type, but table creation requires a [key_to_int] function, which will be used
8-
to extract the integer of all keys. If multiple keys map to the same integer, then
9-
only one of them can be in the table at a time. Any operation that supplies a key
10-
whose corresponding integer is outside the allowed range for the table will cause an
7+
any type, but table creation requires a [key_to_int] function, which will be used to
8+
extract the integer of all keys. If multiple keys map to the same integer, then only
9+
one of them can be in the table at a time. Any operation that supplies a key whose
10+
corresponding integer is outside the allowed range for the table will cause an
1111
exception.
1212
1313
A [Bounded_int_table] is implemented using two fixed-size arrays of size [num_keys],
@@ -16,8 +16,7 @@
1616
single element ([find], [mem], [add], [remove], [set]) take constant time, and perform
1717
one or two array operations. Operations that deal with all of the keys defined in the
1818
table ([data], [fold], [iter], [keys], [to_alist]) take time proportional to the
19-
[length] of the table, not [num_keys].
20-
*)
19+
[length] of the table, not [num_keys]. *)
2120

2221
open! Core
2322

@@ -27,11 +26,11 @@ type ('a, 'b) table = ('a, 'b) t
2726
include Invariant.S2 with type ('a, 'b) t := ('a, 'b) t
2827

2928
(** Equality only requires the keys and values to be the same, not the bin or sexp
30-
formatting or the integers the keys correspond to (see [key_to_int]).*)
29+
formatting or the integers the keys correspond to (see [key_to_int]). *)
3130
include Equal.S2 with type ('a, 'b) t := ('a, 'b) t
3231

33-
(** [create ~num_keys ~key_to_int] returns a table where the keys can map to 0
34-
... [num_keys] - 1, according to [key_to_int]. It is an error if [num_keys < 0].
32+
(** [create ~num_keys ~key_to_int] returns a table where the keys can map to 0 ...
33+
[num_keys] - 1, according to [key_to_int]. It is an error if [num_keys < 0].
3534
3635
[sexp_of_key], if supplied, will be used to display keys in error messages. *)
3736
val create

0 commit comments

Comments
 (0)