-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
If we enable flexible instances, we can define
instance Ord a => Eq (BinomHeap a) where
(==) = (==) `on` extractHeap
instance Ord a => Ord (BinomHeap a) where
compare = compare `on` extractHeapThen
deriving instance Ord a => Eq (MinQueue a)
instance Ord a => Ord (MinQueue a) where
Empty `compare` Empty = EQ
Empty `compare` _ = LT
_ `compare` Empty = GT
MinQueue _n1 x1 q1 `compare` MinQueue _n2 x2 q2 = compare (x1,q1) (x2,q2)I haven't compared the Core this generates to what we do now, but I expect it would be similar. The advantage is that this strikes me as significantly easier to read at a glance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels