Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use private types in the interface #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions opam
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
opam-version: "1.2"
name: "usane"
maintainer: "Hannes Mehnert <hannes@mehnert.org>"
authors: ["Hannes Mehnert <hannes@mehnert.org>"]
homepage: "https://github.com/hannesm/usane"
Expand Down
8 changes: 8 additions & 0 deletions src/usane.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module Uint8 = struct
external mul : t -> t -> t * bool = "caml__uint8_mul_overflow"
external sub : t -> t -> t * bool = "caml__uint8_sub_overflow"

let zero = 0

let pred t = sub t 1

let succ t = add t 1
Expand Down Expand Up @@ -54,6 +56,8 @@ module Uint16 = struct
external mul : t -> t -> t * bool = "caml__uint16_mul_overflow"
external sub : t -> t -> t * bool = "caml__uint16_sub_overflow"

let zero = 0

let pred t = sub t 1

let succ t = add t 1
Expand Down Expand Up @@ -100,6 +104,8 @@ module Uint32 = struct
external mul : t -> t -> t * bool = "caml_uint32_mul_overflow"
external sub : t -> t -> t * bool = "caml_uint32_sub_overflow"

let zero = 0l

let pred t = sub t 1l

let succ t = add t 1l
Expand Down Expand Up @@ -144,6 +150,8 @@ module Uint64 = struct
external mul : t -> t -> t * bool = "caml_uint64_mul_overflow"
external sub : t -> t -> t * bool = "caml_uint64_sub_overflow"

let zero = 0L

let pred t = sub t 1L

let succ t = add t 1L
Expand Down
16 changes: 14 additions & 2 deletions src/usane.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
module Uint8 : sig

(** Type of an unsigned 8 bit integer. It is represented as an [int]*)
type t = int
type t = private int

(** [pp ppf u] prints the unsigned 8bit integer in hex encoding. *)
val pp : Format.formatter -> t -> unit
Expand Down Expand Up @@ -55,6 +55,9 @@ module Uint8 : sig
is [true], otherwise it is [false]. *)
val pred : t -> t * bool

(** [zero] is [Uint8.of_int 0] *)
val zero : t

(** [compare t t'] is
{ul
{- [-1] if [t] is smaller than [t'],}
Expand Down Expand Up @@ -88,7 +91,7 @@ end
module Uint16 : sig

(** Type of an unsigned 16 bit integer. It is represented as an [int]*)
type t = int
type t = private int

(** [pp ppf u] prints the unsigned 16bit integer in hex encoding. *)
val pp : Format.formatter -> t -> unit
Expand Down Expand Up @@ -119,6 +122,9 @@ module Uint16 : sig
is [true], otherwise it is [false]. *)
val pred : t -> t * bool

(** [zero] is [Uint16.of_int 0] *)
val zero : t

(** [compare t t'] is
{ul
{- [-1] if [t] is smaller than [t'],}
Expand Down Expand Up @@ -188,6 +194,9 @@ module Uint32 : sig
is [true], otherwise it is [false]. *)
val pred : t -> t * bool

(** [zero] is [Uint32.of_int 0] *)
val zero : t

(** [compare t t'] is
{ul
{- [-1] if [t] is smaller than [t'],}
Expand Down Expand Up @@ -257,6 +266,9 @@ module Uint64 : sig
is [true], otherwise it is [false]. *)
val pred : t -> t * bool

(** [zero] is [Uint64.of_int 0] *)
val zero : t

(** [compare t t'] is
{ul
{- [-1] if [t] is smaller than [t'],}
Expand Down
Loading