Skip to content

Get rid of eqExtract and cmpExtract? #62

@treeowl

Description

@treeowl

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` extractHeap

Then

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions