package core

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file list.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
include List0 (** @inline *)

(* This function is staged to indicate that real work (the functor application) takes
   place after a partial application. *)
let stable_dedup_staged (type a) ~(compare : a -> a -> int)
  : (a list -> a list) Base.Staged.t
  =
  let module Set =
    Set.Make (struct
      type t = a

      let compare = compare

      (* [stable_dedup_list] never calls these *)
      let t_of_sexp _ = assert false
      let sexp_of_t _ = assert false
    end)
  in
  Base.Staged.stage Set.stable_dedup_list
;;

let zip_with_remainder =
  let rec zip_with_acc_and_remainder acc xs ys =
    match xs, ys with
    | [], [] -> rev acc, None
    | fst, [] -> rev acc, Some (Either.First fst)
    | [], snd -> rev acc, Some (Either.Second snd)
    | x :: xs, y :: ys -> zip_with_acc_and_remainder ((x, y) :: acc) xs ys
  in
  fun xs ys -> zip_with_acc_and_remainder [] xs ys
;;

type sexp_thunk = unit -> Base.Sexp.t

let sexp_of_sexp_thunk x = x ()

exception Duplicate_found of sexp_thunk * Base.String.t [@@deriving sexp]

let exn_if_dup ~compare ?(context = "exn_if_dup") t ~to_sexp =
  match find_a_dup ~compare t with
  | None -> ()
  | Some dup -> raise (Duplicate_found ((fun () -> to_sexp dup), context))
;;

let slice a start stop =
  Ordered_collection_common.slice ~length_fun:length ~sub_fun:sub a start stop
;;

module Stable = struct
  module V1 = struct
    type nonrec 'a t = 'a t [@@deriving sexp, sexp_grammar, bin_io, compare]

    let stable_witness = List0.stable_witness [@@alert "-for_internal_use_only"]
  end
end
OCaml

Innovation. Community. Security.