Heaps in core_kernel

194 views
Skip to first unread message

RJ Nowling

unread,
Apr 12, 2020, 3:37:04 PM4/12/20
to ocaml-core
Hi,

I'm a new OCaml user.  I installed OCaml 4.10 and Base / Core_kernel / Core v0.13.0 via opam.

I'm trying to use the Pairing heap or hash heap from Core_kernel.  I found the source for each on GitHub:



But I don't see them listed in the API documentation for Core_kernel:


I tried to modify some code from the Pairing_heap benchmark and run into error saying that Pairing_heap module is missing:

open Core
open Stdio

let create_heap size =
  let h = Pairing_heap.create ~cmp:Int.compare () in
  for i = 1 to size do
    Heap.add h i
  done

let () = Stdio.Out_channel.output_string stdout "Hello, world!\n"           

File "dot2dot.ml", line 5, characters 10-29:
5 |   let h = Pairing_heap.create ~cmp:Int.compare () in
              ^^^^^^^^^^^^^^^^^^^
Error: Unbound module Pairing_heap

So, a couple of questions:

1. Why aren't Pairing_heap and Hash_heap listed in the API documentation?
2. Is there any I should look into to help me figure out why I can't import the heaps?

Thank you in advance!

RJ

RJ Nowling

unread,
Apr 12, 2020, 5:10:45 PM4/12/20
to ocaml-core
As a follow up, I was able to compile the code by:

1. adding core_kernel.pairing_heap to my dune file.  I don't understand by core_kernel was insufficient.  I guess pairing_heap isn't linked as part of Core_kernel?

2. Changing Heap to Pairing_Heap

This post led to me figure this out:


Absence from API docs is still an issue, though.
Reply all
Reply to author
Forward
0 new messages