Skip to content

Why is MVector's constructor exposed? #517

@tomjaguarpaw

Description

@tomjaguarpaw

The constructor of MVector is exposed:

data MVector s a  = MVector !Int !Int !(MutableArray s a)

This seems pretty odd, because the two Ints are the offset into the underlying MutableArray that the MVector starts, and the length of the MVector. both of which are used for bounds checking before deferring to readArray of a MutableArray via basicUnsafeRead.

So I'm confused. Firstly, can changing those fields not lead to segfaults? And secondly, doesn't changing those fields have no real purpose, since there are better ways of obtaining the ends one wants via the safe API (or even the unsafe one, with functions explicitly named as "unsafe" if one really wants the performance)?

Or have I missed something, and there is a good reason for exposing those fields?

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