ekmett / ekmett/heaps

Heap can't handle infinite values?

Open
#20 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
34
Forks
9
PR merge metrics
No merged PRs in 30d

Description

```haskell
ghci> import Prelude as Pre
ghci> import Data.Heap as Heap
ghci> Heap.map (Pre.take 4) $ Heap.insert [3..] $ Heap.adjustMin tail $ Heap.insert [1..] Heap.empty
fromList [[2,3,4,5],[3,4,5,6]]
ghci> Heap.map (Pre.take 4) $ Heap.adjustMin tail $ Heap.insert [3..] $ Heap.insert [1..] Heap.empty
( hangs )
Interrupted.
ghci>
```

I do not immediately see a reason for this behaviour.

When wrapping the infinite lists in an `Entry { priority = head xs, payload = xs }`, the hang disappears.

This behaviour might somehow be expected or intended, but I could not find any mention of strictness in the docs. Ideally, `Heap` would accept infinite values.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the GHCi examples from the issue with infinite lists in Data.Heap, comparing the hanging raw-list case with the Entry wrapper that completes. Inspect how heap ordering and strictness handle these values; done should clarify whether infinite values are supported and, if so, provide the corresponding fix or documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.