Where to find Heaps in Core?

Since there are no heaps in the standard library, I did a bit of research to find a usable module. This post on StackOverflow mentionned a submodule Heap in the Core.Std module. However, this module does not exist anymore.

This post asked the question, and an answer pointing to Core_kernel was given. Again, I tried to install this module, only to be met with a warning:

Alert deprecated: module Core_kernel
[since 2021-05] Use [Core] -- [Core_kernel] was renamed as [Core]

(and even without the warning, the last version of Core_kernel does not have a pairing_heap submodule.)

I would like to know if the heap datastructure is hidden somewhere I didn’t find it in the Core module. I found an alternative in Batteries, but I would like to avoid multiplying modules to install.

Thanks a bunch for any answer.

PS: I did not reply to the post on ocaml org, because the last 3 posts were completely irrelevent to the topic.

Heaps have been moved into sub-libraries under core_kernel: e.g. core_kernel.pairing_heap.

FYI, you can see these libraries in the output of ocamlfind query.

Edit: my bad, didn’t realize you’d already seen the post about sublibraries. I think core_kernel does still have a pairing_heap sublibrary, and the right thing to do is ignore that warning.

I think the nuance here is that the library (the thing you specify in Dune, assuming that you’re using Dune) is called core_kernel.pairing_heap, but the module brought into scope by that library is just called Pairing_heap. So you want to have a setup like the following:

;; In your dune file
 (name main)
 (libraries core_kernel.pairing_heap))
(* In an OCaml file like main.ml *)
let () =
  let heap = Pairing_heap.of_list [ 1; 2; 5 ] ~cmp:Int.compare in
  Printf.printf "%d\n" (Pairing_heap.length heap)