You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
treeowl
added a commit
to treeowl/primitive-unlifted
that referenced
this issue
Oct 20, 2020
* Use a newtype to hide the unrestricted `ByteArray`
underneath.
* Mark `Data.Primitive.Unlifted.Class` as `Trustworthy`. TODO:
Discuss whether it's okay to do that without similarly changing
the `PrimArray` instance.
Closeshaskell-primitive#22
* Use a newtype to hide the unrestricted `ByteArray`
underneath.
* Mark `Data.Primitive.Unlifted.Class` as `Trustworthy`. TODO:
Discuss whether it's okay to do that without similarly changing
the `PrimArray` instance.
Closeshaskell-primitive#22
The
PrimUnlifted ShortText
instance usesfromShortByteStringUnsafe
, which is consideredUnsafe
. 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 intext-short
, I'd be worried.Here's what I suggest: define an unlifted newtype around
ByteArray#
in anUnsafe
module. Use that as the definition ofUnlifted ShortText
. MarkData.Primitive.Unlifted.Class
asTrustworthy
. Users who just want to be able to make unlifted containers ofShortText
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.The text was updated successfully, but these errors were encountered: