Skip to content

Commit 259754a

Browse files
v0.18~preview.130.100+614
1 parent ef9cb88 commit 259754a

116 files changed

Lines changed: 3015 additions & 1801 deletions

File tree

Some content is hidden

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

base.opam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ build: [
1212
]
1313
depends: [
1414
"ocaml" {>= "5.1.0"}
15+
"base_internalhash_types"
1516
"basement"
1617
"capsule0"
18+
"nonempty_list_type"
1719
"ocaml_intrinsics_kernel"
1820
"ppx_array_base"
1921
"ppx_base"
20-
"ppx_cold"
21-
"ppx_hash"
2222
"ppxlib_jane"
2323
"sexplib0"
2424
"dune" {>= "3.17.0"}
2525
"dune-configurator"
2626
"ppxlib" {>= "0.33.0" & < "0.36.0"}
2727
]
28-
available: arch != "arm32" & arch != "x86_32"
28+
available: arch != "x86_32"
2929
synopsis: "Full standard library replacement for OCaml"
3030
description: "
3131
Full standard library replacement for OCaml

lint/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(library
22
(name ppx_base_lint)
33
(kind ppx_rewriter)
4-
(libraries compiler-libs.common ppx_cold ppxlib ppxlib_jane ppxlib.stdppx)
4+
(libraries compiler-libs.common ppxlib ppxlib_jane ppxlib.stdppx)
55
(preprocess no_preprocessing))

lint/ppx_base_lint.ml

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
open Ppxlib
22
open Stdppx
33

4-
let expand_cold = ref true
54
let error ~loc fmt = Location.raise_errorf ~loc (Stdlib.( ^^ ) "ppx_base_lint:" fmt)
65

76
type suspicious_id = Stdlib_submodule of string
@@ -42,23 +41,6 @@ let rec is_stdlib_dot_something : Longident.t -> bool = function
4241
| _ -> false
4342
;;
4443

45-
let print_payload ppf = function
46-
| PStr x -> Pprintast.structure ppf x
47-
| PSig x -> Pprintast.signature ppf x
48-
| PTyp x -> Pprintast.core_type ppf x
49-
| PPat (x, None) -> Pprintast.pattern ppf x
50-
| PPat (x, Some w) ->
51-
Stdlib.Format.fprintf ppf "%a@ when@ %a" Pprintast.pattern x Pprintast.expression w
52-
;;
53-
54-
let remove_loc =
55-
object
56-
inherit Ast_traverse.map
57-
method! location _ = Location.none
58-
method! location_stack _ = []
59-
end
60-
;;
61-
6244
let check current_module =
6345
let zero_modules = zero_modules () in
6446
object
@@ -105,75 +87,6 @@ let check current_module =
10587
~loc:mb.pmb_loc
10688
"you cannot alias [Stdlib] sub-modules, use them directly"
10789
| _ -> ())
108-
109-
method! attributes attrs =
110-
super#attributes attrs;
111-
if !expand_cold
112-
then (
113-
let is_cold attr = String.equal attr.attr_name.txt "cold" in
114-
match List.find_opt attrs ~f:is_cold with
115-
| None -> ()
116-
| Some attr ->
117-
let expansion =
118-
Ppx_cold.expand_cold_attribute attr
119-
|> List.map ~f:(fun a ->
120-
{ a with
121-
attr_name =
122-
{ a.attr_name with
123-
txt =
124-
(let string = a.attr_name.txt
125-
and prefix = "ocaml." in
126-
if String.is_prefix string ~prefix
127-
then String.drop_prefix string (String.length prefix)
128-
else string)
129-
}
130-
})
131-
in
132-
let is_part_of_expansion attr =
133-
List.exists expansion ~f:(fun a ->
134-
String.equal a.attr_name.txt attr.attr_name.txt
135-
|| String.equal ("ocaml." ^ a.attr_name.txt) attr.attr_name.txt)
136-
in
137-
let new_attrs =
138-
List.concat_map attrs ~f:(fun a ->
139-
if is_cold a
140-
then a :: expansion
141-
else if is_part_of_expansion a
142-
then []
143-
else [ a ])
144-
in
145-
if not
146-
(Poly.equal
147-
(remove_loc#attributes attrs)
148-
(remove_loc#attributes new_attrs))
149-
then (
150-
(* Remove attributes written by the user that correspond to attributes in the
151-
expansion *)
152-
List.iter attrs ~f:(fun a ->
153-
if is_part_of_expansion a
154-
then Driver.register_correction ~loc:a.attr_loc ~repl:"");
155-
let attribute_level =
156-
String.make
157-
(attr.attr_name.loc.loc_start.pos_cnum
158-
- attr.attr_loc.loc_start.pos_cnum
159-
- 1)
160-
'@'
161-
in
162-
let repl =
163-
Stdlib.Format.asprintf
164-
"@[<h>%a@]"
165-
(Stdlib.Format.pp_print_list (fun ppf x ->
166-
Stdlib.Format.fprintf
167-
ppf
168-
"[%s%s@ %a]"
169-
attribute_level
170-
x.attr_name.txt
171-
print_payload
172-
x.attr_payload))
173-
(attr :: expansion)
174-
in
175-
Driver.register_correction ~loc:attr.attr_loc ~repl);
176-
Ppxlib.Attribute.mark_as_handled_manually attr)
17790
end
17891
;;
17992

@@ -183,10 +96,6 @@ let module_of_loc (loc : Location.t) =
18396
;;
18497

18598
let () =
186-
Ppxlib.Driver.add_arg
187-
"-do-not-correct-cold-attributes"
188-
(Clear expand_cold)
189-
~doc:"do not automatically expand [@cold] attributes";
19099
Ppxlib.Driver.register_transformation
191100
"base_lint"
192101
~impl:(function

ppx/src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(library
22
(name ppx_base_internal)
3-
(kind ppx_deriver)
3+
(kind ppx_rewriter)
44
(libraries ppxlib ppxlib_jane ppxlib.stdppx)
55
(preprocess
66
(pps ppxlib.metaquot)))

src/array.ml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -470,17 +470,14 @@ let max_elt t ~compare =
470470

471471
let[@inline always] findi_internal t ~f ~if_found ~if_not_found =
472472
let length = length t in
473-
if length = 0
474-
then (if_not_found [@inlined]) ()
475-
else (
476-
let rec loop i =
477-
if i < length
478-
then (
479-
let x = unsafe_get t i in
480-
if (f [@inlined hint]) i x then (if_found [@inlined]) ~i ~value:x else loop (i + 1))
481-
else (if_not_found [@inlined]) ()
482-
in
483-
(loop [@inlined]) 0 [@nontail])
473+
let rec loop i =
474+
if i < length
475+
then (
476+
let x = unsafe_get t i in
477+
if (f [@inlined hint]) i x then (if_found [@inlined]) ~i ~value:x else loop (i + 1))
478+
else (if_not_found [@inlined]) ()
479+
in
480+
(loop [@inlined]) 0 [@nontail]
484481
[@@kind k1 = k1, k2 = (value_or_null, k1, value_or_null & k1)]
485482
;;
486483

@@ -997,6 +994,22 @@ let map_inplace t ~f =
997994
done
998995
;;
999996

997+
let find_or_null t ~f =
998+
(findi_internal [@inlined])
999+
t
1000+
~f:(fun _i x -> f x)
1001+
~if_not_found:(fun () -> Null)
1002+
~if_found:(fun ~i:_ ~value:v -> This v) [@nontail]
1003+
;;
1004+
1005+
let findi_or_null t ~f =
1006+
(findi_internal [@inlined])
1007+
t
1008+
~f
1009+
~if_not_found:(fun () -> Null)
1010+
~if_found:(fun ~i ~value:v -> This (i, v)) [@nontail]
1011+
;;
1012+
10001013
let find_consecutive_duplicate t ~equal =
10011014
let n = length t in
10021015
if n <= 1

src/array0.mli

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,19 @@ val concat : 'a. 'a array list -> 'a array]
4949

5050
val max_length : int
5151
val create_float_uninitialized : len:int -> float array
52-
val blit : src:'a array -> src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> unit
53-
val make_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
5452

55-
val%template fold_right : 'a array -> f:('a -> 'b -> 'b) -> init:'b -> 'b
56-
[@@mode m = (uncontended, shared)]
53+
include sig
54+
[@@@implicit_kind: 'a]
55+
[@@@implicit_kind: 'b]
5756

58-
val stable_sort : 'a array -> compare:('a -> 'a -> int) -> unit
57+
val blit : src:'a array -> src_pos:int -> dst:'a array -> dst_pos:int -> len:int -> unit
58+
val make_matrix : dimx:int -> dimy:int -> 'a -> 'a array array
59+
60+
val%template fold_right : 'a array -> f:('a -> 'b -> 'b) -> init:'b -> 'b
61+
[@@mode m = (uncontended, shared)]
62+
63+
val stable_sort : 'a array -> compare:('a -> 'a -> int) -> unit
64+
end
5965

6066
[%%template:
6167
[@@@kind.default k' = (base_or_null, value_or_null mod external64)]

0 commit comments

Comments
 (0)