package ocamlformat-lib

  1. Overview
  2. Docs
OCaml Code Formatter

Install

Dune Dependency

Authors

Maintainers

Sources

ocamlformat-0.26.2.tbz
sha256=2e4f596bf7aa367a844fe83ba0f6b0bf14b2a65179ddc082363fe9793d0375c5
sha512=b03d57462e65b11aa9f78dd5c4548251e8d1c5a1c9662f7502bdb10472aeb9df33c1d407350767a5223fbff9c01d53de85bafacd0274b49abc4b43701b159bee

doc/ocamlformat-lib.ocamlformat_stdlib/Ocamlformat_stdlib/Int_conversions/index.html

Module Ocamlformat_stdlib.Int_conversionsSource

include module type of struct include Base.Int_conversions end
Sourceval int_to_int32 : int -> int32 option

Ocaml has the following integer types, with the following bit widths on 32-bit and 64-bit architectures.

                        arch  arch
            type        32b   64b
            ----------------------
            int          31    63  (32 when compiled to JavaScript)
            nativeint    32    64
            int32        32    32
            int64        64    64

In both cases, the following inequalities hold:

  width(int) < width(nativeint)
  && width(int32) <= width(nativeint) <= width(int64)

The conversion functions come in one of two flavors.

If width(foo) <= width(bar) on both 32-bit and 64-bit architectures, then we have

 val foo_to_bar : foo -> bar 

otherwise we have

  val foo_to_bar     : foo -> bar option
  val foo_to_bar_exn : foo -> bar
Sourceval int_to_int32_exn : int -> int32
Sourceval int_to_int32_trunc : int -> int32
Sourceval int_to_int64 : int -> int64
Sourceval int_to_nativeint : int -> nativeint
Sourceval int32_to_int : int32 -> int option
Sourceval int32_to_int_exn : int32 -> int
Sourceval int32_to_int_trunc : int32 -> int
Sourceval int32_to_int64 : int32 -> int64
Sourceval int32_to_nativeint : int32 -> nativeint
Sourceval int32_is_representable_as_int : int32 -> bool
Sourceval int64_to_int : int64 -> int option
Sourceval int64_to_int_exn : int64 -> int
Sourceval int64_to_int_trunc : int64 -> int
Sourceval int64_to_int32 : int64 -> int32 option
Sourceval int64_to_int32_exn : int64 -> int32
Sourceval int64_to_int32_trunc : int64 -> int32
Sourceval int64_to_nativeint : int64 -> nativeint option
Sourceval int64_to_nativeint_exn : int64 -> nativeint
Sourceval int64_to_nativeint_trunc : int64 -> nativeint
Sourceval int64_fit_on_int63_exn : int64 -> unit
Sourceval int64_is_representable_as_int63 : int64 -> bool
Sourceval nativeint_to_int : nativeint -> int option
Sourceval nativeint_to_int_exn : nativeint -> int
Sourceval nativeint_to_int_trunc : nativeint -> int
Sourceval nativeint_to_int32 : nativeint -> int32 option
Sourceval nativeint_to_int32_exn : nativeint -> int32
Sourceval nativeint_to_int32_trunc : nativeint -> int32
Sourceval nativeint_to_int64 : nativeint -> int64
Sourceval num_bits_int : int
Sourceval num_bits_int32 : int
Sourceval num_bits_int64 : int
Sourceval num_bits_nativeint : int
Sourcemodule Make (I : sig ... end) : sig ... end

human-friendly string (and possibly sexp) conversions

Sourcemodule Make_hex (I : sig ... end) : sig ... end

in the output, to_string, of_string, sexp_of_t, and t_of_sexp convert between t and signed hexadecimal with an optional "0x" or "0X" prefix.

Sourcemodule Make_binary (I : sig ... end) : sig ... end

in the output, to_string, to_string_hum, and sexp_of_t convert t to an unsigned binary representation with an "0b" prefix.

Sourceval sexp_of_int_style : [ `No_underscores | `Underscores ] ref

global ref affecting whether the sexp_of_t returned by Make is consistent with the to_string input or the to_string_hum output

Sourceval insert_delimiter_every : string -> delimiter:char -> chars_per_delimiter:int -> string

utility for defining to_string_hum on numeric types -- takes a string matching (-|+)?0-9a-fA-F+ and puts delimiter every chars_per_delimiter characters starting from the right.

Sourceval insert_delimiter : string -> delimiter:char -> string

insert_delimiter_every ~chars_per_delimiter:3

Sourceval insert_underscores : string -> string

insert_delimiter ~delimiter:'_'

OCaml

Innovation. Community. Security.