tweag / tweag/linear-base

Movable for amortized structures

Open
#445 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
359
Forks
45
PR merge metrics
No merged PRs in 30d

Description

In some cases, a pure amortized data structure may only be efficient when used in a single threaded fashion. This suggests a linear interface

-- Pairing heaps
data PQ a = ...

insert :: Ord a => a -> PQ a %1-> PQ a
merge :: Ord a => PQ a %1-> PQ a %1-> PQ a
extractMin :: Ord a => PQ a %1-> Maybe (Ur a, PQ a)

Would it be appropriate for something like PQ a to be an instance of Moveable? If so, move would be a no-op (move = Unsafe.coerce Ur), and the user would be fully responsible for making sure performance was okay in context. Or would it be better to only have a perflyRiskyMove in the module to make it clear that there's a performance risk?

The Dupable instance is much more obviously reasonable: it would fully reassociate the queue into a "safe" configuration that has no credit. Do we want to provide a module giving an example of a structure like this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the existing Moveable and Dupable interfaces alongside the proposed Pairing heap API. Determine whether a no-op Moveable instance, a clearly risky move operation, or only a Dupable example is appropriate; done means the project has a settled design and documented example or rationale.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.