add CCInt64 to containers

This commit is contained in:
Simon Cruanes 2015-09-22 22:29:21 +02:00
parent d33b52e6f3
commit 6cb74b0115
5 changed files with 140 additions and 1 deletions

View file

@ -116,6 +116,7 @@ Documentation http://cedeela.fr/~simon/software/containers[here].
- `CCHash` (hashing combinators) - `CCHash` (hashing combinators)
- `CCError` (monadic error handling, very useful) - `CCError` (monadic error handling, very useful)
- `CCIO`, basic utilities for IO (channels, files) - `CCIO`, basic utilities for IO (channels, files)
- `CCInt64,` utils for `int64`
=== Containers.data === Containers.data

2
_oasis
View file

@ -45,7 +45,7 @@ Library "containers"
Path: src/core Path: src/core
Modules: CCVector, CCPrint, CCError, CCHeap, CCList, CCOpt, CCPair, Modules: CCVector, CCPrint, CCError, CCHeap, CCList, CCOpt, CCPair,
CCFun, CCHash, CCInt, CCBool, CCFloat, CCArray, CCRef, CCSet, CCFun, CCHash, CCInt, CCBool, CCFloat, CCArray, CCRef, CCSet,
CCOrd, CCRandom, CCString, CCHashtbl, CCMap, CCFormat, CCIO, CCOrd, CCRandom, CCString, CCHashtbl, CCMap, CCFormat, CCIO, CCInt64,
Containers Containers
BuildDepends: bytes BuildDepends: bytes
# BuildDepends: bytes, bisect_ppx # BuildDepends: bytes, bisect_ppx

View file

@ -33,6 +33,7 @@ CCHash
CCHashtbl CCHashtbl
CCHeap CCHeap
CCInt CCInt
CCInt64
CCIO CCIO
CCList CCList
CCMap CCMap

56
src/core/CCInt64.ml Normal file
View file

@ -0,0 +1,56 @@
(* This file is free software, part of containers. See file "license" for more details. *)
include Int64
let (+) = add
let (-) = sub
let (~-) = neg
let ( * ) = mul
let (/) = div
let (mod) = rem
let (land) = logand
let (lor) = logor
let (lxor) = logxor
let lnot = lognot
let (lsl) = shift_left
let (lsr) = shift_right_logical
let (asr) = shift_right
let equal (x:t) y = x=y
let hash x = Pervasives.abs (to_int x)
(** {2 Conversion} *)
let of_int_exn = of_int
let of_int x = try Some (of_int_exn x) with Failure _ -> None
let of_nativeint_exn = of_nativeint
let of_nativeint x = try Some (of_nativeint_exn x) with Failure _ -> None
let of_int32_exn = of_int32
let of_int32 x = try Some (of_int32_exn x) with Failure _ -> None
let of_float_exn = of_float
let of_float x = try Some (of_float_exn x) with Failure _ -> None
let of_string_exn = of_string
let of_string x = try Some (of_string_exn x) with Failure _ -> None

81
src/core/CCInt64.mli Normal file
View file

@ -0,0 +1,81 @@
(* This file is free software, part of containers. See file "license" for more details. *)
(** {1 Int64}
Helpers for in64.
@since NEXT_RELEASE *)
type t = int64
val (+) : t -> t -> t
val (-) : t -> t -> t
val (~-) : t -> t
val ( * ) : t -> t -> t
val (/) : t -> t -> t
val (mod) : t -> t -> t
val abs : t -> t
val max_int : t
val min_int : t
val (land) : t -> t -> t
val (lor) : t -> t -> t
val (lxor) : t -> t -> t
val lnot : t -> t
val (lsl) : t -> int -> t
val (lsr) : t -> int -> t
val (asr) : t -> int -> t
val equal : t -> t -> bool
val compare : t -> t -> int
val hash : t -> int
(** {2 Conversion} *)
val to_int : t -> int
val of_int : int -> t option
val of_int_exn : int -> t
val to_int32 : t -> int32
val of_int32 : int32 -> t option
val of_int32_exn : int32 -> t
val to_nativeint : t -> nativeint
val of_nativeint : nativeint -> t option
val of_nativeint_exn : nativeint -> t
val to_float : t -> float
val of_float : float -> t option
val of_float_exn : float -> t
val to_string : t -> string
val of_string : string -> t option
val of_string_exn : string -> t