Skip to content

The PrimUnlifted ShortText instance is unsafe #22

@treeowl

Description

@treeowl

The PrimUnlifted ShortText instance uses fromShortByteStringUnsafe, which is considered Unsafe. I don't know just how wrong things can go if the bytestring isn't properly encoded, but based on the liberal "Unsafe!" warnings around FFI in text-short, I'd be worried.

Here's what I suggest: define an unlifted newtype around ByteArray# in an Unsafe module. Use that as the definition of Unlifted ShortText. Mark Data.Primitive.Unlifted.Class as Trustworthy. Users who just want to be able to make unlifted containers of ShortText won't have to change anything. Those who actually need to mess with the unlifted representation can import the unsafe module and do what they like.

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