[ghc-steering-committee] Array resizing primitives (#121), proposal: accept with modifications

Simon Marlow marlowsd at gmail.com
Fri May 18 08:24:02 UTC 2018


I propose that we accept https://github.com/ghc-
proposals/ghc-proposals/pull/121
With one modification (below).

In summary, this proposal suggests adding primitives for resizing
(shrinking or expanding) primitives mutable arrays of pointers. See the
proposal for motivation. There would be two primitives per array type:

shrinkArray# :: MutableArray# s a -> Int# -> State# s -> State# s
resizeArray# :: MutableArray# s a -> Int# -> a -> State# s -> (# State# s,
MutableArray# s a #)

(these mirror the existing shrink and resize primitives we have for
ByteArray#, with the same rationale)

The biggest downside is that we currently have

  sizeOfMutableArray# :: MutableArray# s a -> Int #

which would need to be replaced by a stateful operation

  getSizeOfMutableArray# :: MutableArray# s a -> State# s -> (# State# s,
Int# #)

So we would need to deprecate the old primops, update any code we have that
uses them, and clearly indicate the unsafety in the docs. But this has
knock-on effects in Data.Primitive:

sizeofMutableArray :: MutableArray s a -> Int

this would need to be deprecated and replaced by a PrimMonad operation.
The pure version would be unsafe in the sense that it could return the
wrong size, and a future indexing operation relying on the incorrect size
could access an out-of-bounds element.

Suggested modifications:
* Remove the ArrayArray# primitives, add UniftedArray# primitives instead
(see
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0021-unlifted-array.rst
)

Cheers
Simon


On 1 May 2018 at 13:12, Joachim Breitner <mail at joachim-breitner.de> wrote:

> Dear Committee,
>
> this is your secretary speaking:
>
> Array resizing primitives have been proposed by David Feuer:
> https://github.com/ghc-proposals/ghc-proposals/pull/121
>
> I propose Simon Marlow as the shepherd.
>
> Simon, please reach consensus as described in
> https://github.com/ghc-proposals/ghc-proposals#committee-process
>
> I suggest you make a recommendation, in a new e-mail thread with the
> proposal number in the subject, about the decision, maybe point out
> debatable points, and assume that anyone who stays quiet agrees with
> you.
>
> Thanks,
> --
> Joachim Breitner
>   mail at joachim-breitner.de
>   http://www.joachim-breitner.de/
>
> _______________________________________________
> ghc-steering-committee mailing list
> ghc-steering-committee at haskell.org
> https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-steering-committee/attachments/20180518/0de25b2f/attachment.html>


More information about the ghc-steering-committee mailing list