Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for boxed but unlifted element types to Primitive.Array #419

Open
dcoutts opened this issue Sep 20, 2024 · 1 comment
Open

Comments

@dcoutts
Copy link

dcoutts commented Sep 20, 2024

Right now, P.Array supports only lifted types (types of kind *)

ghci> :kind Data.Primitive.Array.Array GHC.Exts.ByteArray#

<interactive>:1:28: error: [GHC-83865]
    • Expected a lifted type, but ‘ByteArray#’ is a boxed unlifted type
    • In the first argument of ‘Data.Primitive.Array.Array’, namely
        ‘ByteArray#’
      In the type ‘Data.Primitive.Array.Array ByteArray#’

But, in recent GHC versions, the underlying Array# type supports any boxed (lifted or unlifted) type:

ghci> :kind GHC.Exts.Array# GHC.Exts.ByteArray#
GHC.Exts.Array# GHC.Exts.ByteArray# :: ghc-prim:GHC.Types.UnliftedType

The primitive array type should be similarly extended to support this.

It would be very useful, to reduce allocations and indirections (and easily enforce strictness) when using types like ByteArray#. In particular it would support higher level libraries like vector to provide useful Unbox instances for the wrapper types like ByteArray.

@dcoutts dcoutts changed the title Add support for GHC's levity-polymorphic arrays to Primitive.Array Add support for boxed but unlifted element types to Primitive.Array Sep 20, 2024
@konsumlamm
Copy link
Contributor

See #356.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants