Skip to content

Constructors for immutable unboxed tuple vectors are not exported #504

@ruifengx

Description

@ruifengx

See the following export list for Data.Vector.Unboxed:

module Data.Vector.Unboxed (
-- * Unboxed vectors
Vector(V_UnboxAs, V_UnboxViaPrim), MVector(..), Unbox,

All the constructors for the MVector family are exported, which includes constructors for mutable unboxed tuple vectors (e.g., MV_2). However, for immutable unboxed tuple vectors, the constructors are private.

Currently, to construct an unboxed tuple vector from the two underlying parallel vector without copying, one must go through MVector and unsafeFreeze, which seems a bit weird to me.

import Data.Vector.Unboxed qualified as U
pairUnboxed :: U.Vector a -> U.Vector b -> U.Vector (a, b)
pairUnboxed xs ys = do
    xs' <- unsafeThaw xs
    ys' <- unsafeThaw ys
    let len = U.length xs
    unsafeFreeze (MV_2 len xs' ys')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions