<commit_before>(*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *)

(** Global namespace used when defining the rest of nonstdlib, which is
    extended in NS, the exposed interface of nonstdlib *)

(** Support for [@@deriving compare, equal, sexp] on builtin types *)

include Ppx_compare_lib.Builtin
module Sexp = Sexplib.Sexp
include Ppx_sexp_conv_lib.Conv

(** Iterators *)

module Iter = Iter
include Iter.Import

(** Specialize polymorphic comparison to int *)

module Int_compare = struct
  external ( = ) : int -> int -> bool = "%equal"
  external ( <> ) : int -> int -> bool = "%notequal"
  external ( < ) : int -> int -> bool = "%lessthan"
  external ( > ) : int -> int -> bool = "%greaterthan"
  external ( <= ) : int -> int -> bool = "%lessequal"
  external ( >= ) : int -> int -> bool = "%greaterequal"
  external compare : int -> int -> int = "%compare"
  external equal : int -> int -> bool = "%equal"

  let min x y = if x <= y then x else y
  let max x y = if x >= y then x else y
end

include Int_compare

(** Polymorphic comparison and hashing *)
module Poly = struct
  external ( = ) : 'a -> 'a -> bool = "%equal"
  external ( <> ) : 'a -> 'a -> bool = "%notequal"
  external ( < ) : 'a -> 'a -> bool = "%lessthan"
  external ( > ) : 'a -> 'a -> bool = "%greaterthan"
  external ( <= ) : 'a -> 'a -> bool = "%lessequal"
  external ( >= ) : 'a -> 'a -> bool = "%greaterequal"
  external compare : 'a -> 'a -> int = "%compare"
  external equal : 'a -> 'a -> bool = "%equal"

  let min x y = if x <= y then x else y
  let max x y = if x >= y then x else y
  let hash = Stdlib.Hashtbl.hash
end

module Ord = struct
  include Containers.Ord

  let ( @? ) c1 c2 x y = c1 x y <?> (c2, x, y)

  module Infix = struct
    include Infix

    let ( @? ) = ( @? )
  end
end

(** Function combinators *)

let ( >> ) f g x = g (f x)
let ( << ) f g x = f (g x)

let ( $ ) f g x =
  f x ;
  g x

let ( $> ) x f =
  f x ;
  x

let ( <$ ) f x =
  f x ;
  x

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

(** Tuple operations *)

let fst3 (x, _, _) = x
let snd3 (_, y, _) = y
let trd3 (_, _, z) = z

(** Pretty-printing *)

type 'a pp = Format.formatter -> 'a -> unit
type ('a, 'b) fmt = ('a, Format.formatter, unit, 'b) format4

(** Monadic syntax *)<commit_msg>[sledge] Fix confusing arg naming<commit_after>(*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *)

(** Global namespace used when defining the rest of nonstdlib, which is
    extended in NS, the exposed interface of nonstdlib *)

(** Support for [@@deriving compare, equal, sexp] on builtin types *)

include Ppx_compare_lib.Builtin
module Sexp = Sexplib.Sexp
include Ppx_sexp_conv_lib.Conv

(** Iterators *)

module Iter = Iter
include Iter.Import

(** Specialize polymorphic comparison to int *)

module Int_compare = struct
  external ( = ) : int -> int -> bool = "%equal"
  external ( <> ) : int -> int -> bool = "%notequal"
  external ( < ) : int -> int -> bool = "%lessthan"
  external ( > ) : int -> int -> bool = "%greaterthan"
  external ( <= ) : int -> int -> bool = "%lessequal"
  external ( >= ) : int -> int -> bool = "%greaterequal"
  external compare : int -> int -> int = "%compare"
  external equal : int -> int -> bool = "%equal"

  let min x y = if x <= y then x else y
  let max x y = if x >= y then x else y
end

include Int_compare

(** Polymorphic comparison and hashing *)
module Poly = struct
  external ( = ) : 'a -> 'a -> bool = "%equal"
  external ( <> ) : 'a -> 'a -> bool = "%notequal"
  external ( < ) : 'a -> 'a -> bool = "%lessthan"
  external ( > ) : 'a -> 'a -> bool = "%greaterthan"
  external ( <= ) : 'a -> 'a -> bool = "%lessequal"
  external ( >= ) : 'a -> 'a -> bool = "%greaterequal"
  external compare : 'a -> 'a -> int = "%compare"
  external equal : 'a -> 'a -> bool = "%equal"

  let min x y = if x <= y then x else y
  let max x y = if x >= y then x else y
  let hash = Stdlib.Hashtbl.hash
end

module Ord = struct
  include Containers.Ord

  let ( @? ) c1 c2 x y = c1 x y <?> (c2, x, y)

  module Infix = struct
    include Infix

    let ( @? ) = ( @? )
  end
end

(** Function combinators *)

let ( >> ) f g x = g (f x)
let ( << ) f g x = f (g x)

let ( $ ) f g x =
  f x ;
  g x

let ( $> ) x f =
  f x ;
  x

let ( <$ ) f x =
  f x ;
  x

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

(** Tuple operations *)

let fst3 (x, _, _) = x
let snd3 (_, y, _) = y
let trd3 (_, _, z) = z

(** Pretty-printing *)

type 'a pp = Format.formatter -> 'a -> unit
type ('a, 'b) fmt = ('a, Format.formatter, unit, 'b) format4

(** Monadic syntax *)
{'fraction_non_alphanumeric': 0.16520284399832705, 'fraction_numerical': 0.003345880384776244, 'mean_word_length': 2.609811320754717, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3065173', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1668, 'n_words': 642}