Skip to content

Commit

Permalink
Merge pull request #24 from mbarbin/uid-seeded-hash
Browse files Browse the repository at this point in the history
Add [Trait.Uid.seeded_hash]
  • Loading branch information
mbarbin authored Oct 27, 2024
2 parents 891d828 + f60ffa7 commit 9ca19b7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Added

- Added `Trait.Uid.seeded_hash` (#23, @mbarbin).
- Make the library build with `ocaml.4.14` (#22, @jonahbeckford, @mbarbin).
- Added new checks in CI (build checks on windows and macos) (#21, @mbarbin).
- Added a tutorial with new examples of handler-based polymorphism (#13, @mbarbin).
Expand Down
1 change: 1 addition & 0 deletions src/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Int = struct
include Int

let hash = (Hashtbl.hash : int -> int)
let seeded_hash = (Hashtbl.seeded_hash : int -> int -> int)
end

module List = struct
Expand Down
2 changes: 2 additions & 0 deletions src/import.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module Int : sig

(** We re-export hash functions here to make the code compatible with earlier
ocaml versions. [Stdlib.Int.hash] is available since [ocaml.5.1]. *)

val hash : int -> int
val seeded_hash : int -> int -> int
end

module List : sig
Expand Down
1 change: 1 addition & 0 deletions src/provider.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Trait = struct
let equal = Int.equal
let compare = Int.compare
let hash = Int.hash
let seeded_hash = Int.seeded_hash
end

let uid (t : _ t) = Obj.Extension_constructor.id (extension_constructor t)
Expand Down
1 change: 1 addition & 0 deletions src/provider.mli
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module Trait : sig
val equal : t -> t -> bool
val compare : t -> t -> int
val hash : t -> int
val seeded_hash : int -> t -> int
end

(** A uid is particularly useful when you need to quickly look up or sort
Expand Down

0 comments on commit 9ca19b7

Please sign in to comment.