Stdlib.Pqueue(3)
π Stdlib.Pqueue(3) β the OCaml library one, bestie
okay so real talk: this page lives in the OCaml library manual, section 3. no gatekeeping, let's go π«Ά
β¨ NAME β¨
Stdlib.Pqueue β ngl the original literally just says "no description" π which is giving minimal effort, but we move. it's the priority queue module, okay?
π¦ Module π¦
the whole thing is Module Stdlib.Pqueue, and underneath it's documented as:
Module Pqueue
: (module Stdlib__Pqueue)
like yes queen, that's the internal name, we don't ask questions π
π the functors, one by one π
module type OrderedType = sig endβ the input signature for the functorsPqueue.MakeMinandPqueue.MakeMax. it's the vibe check your element type has to pass β¨module type Min = sig endβ the output signature of the functorPqueue.MakeMin.module MakeMin : (E : OrderedType) -> sig endβ a functor that builds you an implementation of the min-priority queue structure, given a totally ordered type for elements. lowkey iconic.module type Max = sig endβ the output signature of the functorPqueue.MakeMax.module MakeMax : (E : OrderedType) -> sig endβ same energy but flipped: a functor building a max-priority queue structure given a totally ordered type for elements. main character energy π₯
π Polymorphic priority queues π
okay this is the part where it gets more complex β the following functors create polymorphic queues of type 'a t, just like other polymorphic containers (lists, arraysβ¦). they require a notion of "polymorphic elements" 'a elt that can be compared without depending on the values of 'a. yes bestie, comparison without peeking at the payload π
one usage scenario: when the user wants to pass priorities separately from the value stored in the queue. you do this by using pairs priority * 'a as elements. fr fr:
module Prio : OrderedType = ...
module PrioQueue = Pqueue.MakeMinPoly(struct
type 'a t = Prio.t * 'a
let compare (p1, _) (p2, _) = Prio.compare p1 p2
end)
(* for example, we now have: *)
PrioQueue.add: 'a PrioQueue.t -> Prio.t * 'a -> unit
PrioQueue.min_elt: 'a PrioQueue.t -> (Prio.t * 'a) option
to recap, since we're all about the details:
module type OrderedPolyType = sig endβ the input signature of the functorsPqueue.MakeMinPolyandPqueue.MakeMaxPoly. β¨module type MinPoly = sig endβ the output signature of the functorPqueue.MakeMinPoly.module MakeMinPoly : (E : OrderedPolyType) -> sig endβ functor building an implementation of min-priority queues given a totally ordered type for the elements. slay πmodule type MaxPoly = sig endβ the output signature of the functorPqueue.MakeMaxPoly.module MakeMaxPoly : (E : OrderedPolyType) -> sig endβ functor building an implementation of max-priority queues given a totally ordered type for the elements. periodt. π
π friendly reminder from your girl: every single one of these is a signature or functor withsig end/-> sig endin this doc β no extra functions are invented here, so don't come for me if you wanted more, that's literally all the page says π«Ά
okay and finally the cute sign-off π: this page was generated by OCamldoc, dated 2026-06-22, for Stdlib.Pqueue(3). stan a documentation tool that shows up on time. bye bestie, go build a queue π¦β¨π
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms