ocaml-core / base / core / lib / hashable.ml

The branch 'bash' does not exist.
open Core_hashtbl_intf

module Hashtbl = Core_hashtbl

module Table_sig (Key : T0) = Monomorphic (Hashtbl) (Key)

module type S = sig
  type t
  module Hashable : T0 with type t = t
  val hash : t -> int
  val hashable : t hashable
  module Table : Table_sig (Hashable).S
  module Hash_set : Hash_set_intf.S with type elem = t
  module Hash_queue : Hash_queue.S with type Key.t = t
  module Hash_heap : Hash_heap.S with type Key.t = t
end

module Make (T : Hashtbl.Key) : S with type t := T.t = struct
  include T
  let hashable = { hash; compare }
  module Hashable = T
  module Table = Hashtbl.Make (T)
  module Hash_set = Hash_set.Make (T)
  module Hash_queue = Hash_queue.Make (T)
  module Hash_heap = Hash_heap.Make (T)
end

module type S_binable = sig
  type t
  module Hashable : T0 with type t = t
  val hash : t -> int
  val hashable : t hashable
  module Table : sig
    include Core_hashtbl_intf.Monomorphic (Hashtbl) (Hashable).S
    include Binable.S1 with type 'a t := 'a t
  end
  module Hash_set : Hash_set_intf.S_binable with type elem = t
  module Hash_queue : Hash_queue.S with type Key.t = t
  module Hash_heap : Hash_heap.S with type Key.t = t
end

module Make_binable (T : sig
  include Hashtbl.Key
  include Binable.S with type t := t
end) : S_binable with type t := T.t = struct
  module Table = Hashtbl.Make_binable (T)
  module Hashable = T
  module Hash_set = Hash_set.Make_binable (T)
  module Hash_queue = Hash_queue.Make (T)
  module Hash_heap = Hash_heap.Make (T)

  include T
  let hashable = { hash; compare }
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.