Get rid of eqExtract and cmpExtract?
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 17
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
If we enable flexible instances, we can define
```haskell
instance Ord a => Eq (BinomHeap a) where
(==) = (==) `on` extractHeap
instance Ord a => Ord (BinomHeap a) where
compare = compare `on` extractHeap
```
Then
```haskell
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate eqExtract and cmpExtract and the existing Eq and Ord implementations for BinomHeap and MinQueue. Enable the proposed flexible instances, compare the generated Core with the current implementation, and verify that equality and ordering behavior remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100