tweag / tweag/linear-base

Linear Mutable Arrays with Linear Values via Ownership

Open
#253 2 comments 0 reactions 1 assignee View on GitHub

@Divesh-Otwani is already working on this.

Since Oct 8, 2020.

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

Description

Is your feature request related to a problem? Please describe.

We can't have linear values inside Data.Array.Mutable.Linear because then we can't freeze. Namely,

freeze :: Array (Array Int) %1-> Ur (Vector (Array Int))

would be unsafe because the inner arrays can now be read and duplicated, though they are mutable references which need to be single-threaded.

Describe the solution you'd like

We can get around this with some notion of an ownership witness that allows you to freeze because using the inner values requires the witness. This is incorrect but gets at the rough idea:

data Arr :: Own -> Type -> Type where ...

deepFreeze :: Arr o (Arr o' Int) -> Owned o %1-> Ur (Vector (Arr o' Int), Owned o')

use :: Owned o %1-> (Owned o %1-> Ur b) %1-> Ur b
write :: Arr o a -> Int -> a %1-> Owned o %1 -> (Arr o' a, Owned o')

This ^ will require some careful thought to tease out.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.