def Heap.pop
import bend-kit-collections@0.1.4.1/heap.bend as Heapimport Base
68# the top, and the heap without it; None on an empty heap
69def Heap.pop(
70 ~A: Data, ~le: A -> A -> Bool, h: Heap<A>
71) -> Maybe<&1, A & Heap<A>>:
72 match h:
73 case HLeaf{}:
74 None{}
75 case HNode{n, x, l, r}:
76 Some{(x, Heap.merge(~A, ~le, l, r))}