package base

  1. Overview
  2. Docs
Full standard library replacement for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.17.3.tar.gz
md5=2100b0ed13fecf43be86ed45c5b2cc4d
sha512=628610caff7e124631870fa1e29661caac28bdfdb18750ee43b868037da3d65d6dd9023b4be7c4c52405679efb5e865a6632d95606a22b28a36636a6bf706ef3

doc/src/base/poly0.ml.html

Source file poly0.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(** Primitives for polymorphic compare. *)

(*_ Polymorphic compiler primitives can't be aliases as this doesn't play well with
  inlining. (If aliased without a type annotation, the compiler would implement them
  using the generic code doing a C call, and it's this code that would be inlined.) As a
  result we have to copy the [external ...] declaration here. *)
external ( < ) : ('a[@local_opt]) -> ('a[@local_opt]) -> bool = "%lessthan"
external ( <= ) : ('a[@local_opt]) -> ('a[@local_opt]) -> bool = "%lessequal"
external ( <> ) : ('a[@local_opt]) -> ('a[@local_opt]) -> bool = "%notequal"
external ( = ) : ('a[@local_opt]) -> ('a[@local_opt]) -> bool = "%equal"
external ( > ) : ('a[@local_opt]) -> ('a[@local_opt]) -> bool = "%greaterthan"
external ( >= ) : ('a[@local_opt]) -> ('a[@local_opt]) -> bool = "%greaterequal"
external ascending : ('a[@local_opt]) -> ('a[@local_opt]) -> int = "%compare"
external compare : ('a[@local_opt]) -> ('a[@local_opt]) -> int = "%compare"
external equal : ('a[@local_opt]) -> ('a[@local_opt]) -> bool = "%equal"

let descending x y = compare y x
let max x y = Bool0.select (x >= y) x y
let min x y = Bool0.select (x <= y) x y