keT p l r = case rank l >= rank r of
                True  ->  Node p (1 + rank l + rank r) l r
                False ->  Node p (1 + rank l + rank r) r l

-- merge combines two heaps into one. There are two base cases and two
-- recursive cases - see [Two-pass Merging algorithm]. Recursive cases
-- call makeT to ensure that rank invariant is maintained after
-- merging.
[
makeT p l r = case rank l >= rank r of
                True  ->  Node p (1 + rank l + rank r) l r
                False ->  Node p (1 + rank l + rank r) r l

-- merge combines two heaps into one. There are two base cases and two
-- recursive cases - see [Two-pass Merging algorithm]. Recursive cases
-- call makeT to ensure that rank invariant is maintained after
-- merging.
makeT p l r = case rank l >= rank r of
                True  ->  Node p (1 + rank l + rank r) l r
                False ->  Node p (1 + rank l + rank r) r l

-- merge combines two heaps into one. There are two base cases and two
-- recursive cases - see [Two-pass Merging algorithm]. Recursive cases
-- call makeT to ensure that rank invariant is maintained after
-- merging.