forked from haskell-primitive/primitive-unlifted
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make PrimUnlifted ShorText instance safe
* 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. Closes haskell-primitive#22
- Loading branch information
Showing
4 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{-# language MagicHash #-} | ||
|
||
-- | Some types may impose invariants that are not natively | ||
-- enforced by their unlifted forms. This module exports | ||
-- newtypes around those unlifted forms that can be used to | ||
-- write safe @PrimUnlifted@ instances. At present, this is | ||
-- only done for the 'ShortText' type, but others may be added. | ||
-- | ||
-- This module exports only abstract types. To access their | ||
-- constructors, import "Data.Primitive.Unlifted.Types.Unsafe". | ||
|
||
module Data.Primitive.Unlifted.Types | ||
( ShortText# | ||
) where | ||
|
||
import Data.Primitive.Unlifted.Types.Unsafe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{-# language MagicHash #-} | ||
{-# language UnliftedNewtypes #-} | ||
|
||
-- | Some types may impose invariants that are not natively | ||
-- enforced by their unlifted forms. This module defines | ||
-- newtypes around those unlifted forms that can be used to | ||
-- write safe @PrimUnlifted@ instances. At present, this is | ||
-- only done for the 'ShortText' type, but others may be added. | ||
|
||
module Data.Primitive.Unlifted.Types.Unsafe | ||
( ShortText# (..) | ||
) where | ||
|
||
import GHC.Exts (ByteArray#) | ||
|
||
newtype ShortText# = ShortText# ByteArray# |