unlifted 0.2.3.0 → 0.2.4.0
raw patch · 4 files changed
+62/−12 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Data.Text.Short.Unlifted: equalsSingletonChar :: ShortText# -> Char# -> Int#
+ Data.Text.Short.Unlifted: null :: ShortText# -> Int#
+ Data.Text.Short.Unlifted: toByteArray :: ShortText# -> ByteArray#
+ Data.Unlifted: [Lifted] :: forall (a :: UnliftedType). a -> Lifted a
+ Data.Unlifted: [Word128#] :: (# Word64#, Word64# #) -> Word128#
+ Data.Unlifted: class Show# (a :: TYPE r)
+ Data.Unlifted: data Lifted (a :: UnliftedType)
+ Data.Unlifted: instance Data.Unlifted.Show# GHC.Prim.Int#
+ Data.Unlifted: instance GHC.Show.Show a => Data.Unlifted.Show# a
+ Data.Unlifted: newtype Word128# :: TYPE 'TupleRep '[ 'Word64Rep, 'Word64Rep]
+ Data.Unlifted: show# :: Show# a => a -> String
+ Data.Unlifted: showsPrec# :: Show# a => Int -> a -> ShowS
- Control.Monad.IO.Unlifted: newtype IO# :: forall (r :: RuntimeRep). TYPE r -> Type
+ Control.Monad.IO.Unlifted: newtype IO# (a :: TYPE r)
- Data.Either.Void: [EitherVoid#] :: forall (a :: TYPE ('TupleRep '[])) (b :: TYPE ('TupleRep '[])). Word# -> EitherVoid# a b
+ Data.Either.Void: [EitherVoid#] :: forall (a :: ZeroBitType) (b :: ZeroBitType). Word# -> EitherVoid# a b
- Data.Either.Void: newtype EitherVoid# :: TYPE ('TupleRep '[]) -> TYPE ('TupleRep '[]) -> TYPE 'WordRep
+ Data.Either.Void: newtype EitherVoid# (a :: ZeroBitType) (b :: ZeroBitType) :: TYPE 'WordRep
- Data.Maybe.Void: [MaybeVoid#] :: forall (a :: TYPE ('TupleRep '[])). Word# -> MaybeVoid# a
+ Data.Maybe.Void: [MaybeVoid#] :: forall (a :: ZeroBitType). Word# -> MaybeVoid# a
- Data.Maybe.Void: newtype MaybeVoid# :: TYPE ('TupleRep '[]) -> TYPE 'WordRep
+ Data.Maybe.Void: newtype MaybeVoid# (a :: ZeroBitType) :: TYPE 'WordRep
- Data.Text.Short.Unlifted: newtype ShortText# :: TYPE ('BoxedRep 'Unlifted)
+ Data.Text.Short.Unlifted: newtype ShortText# :: UnliftedType
- Data.Unlifted: [Maybe#] :: forall (r :: RuntimeRep) (a :: TYPE r). (# (# #) | a #) -> Maybe# @r a
+ Data.Unlifted: [Maybe#] :: forall (r :: RuntimeRep) (a :: TYPE r). (# (# #) | a #) -> Maybe# a
- Data.Unlifted: [MutablePrimArray#] :: forall (r :: RuntimeRep) (s :: Type) (a :: TYPE r). MutableByteArray# s -> MutablePrimArray# s a
+ Data.Unlifted: [MutablePrimArray#] :: forall (r :: RuntimeRep) a (b :: TYPE r). MutableByteArray# a -> MutablePrimArray# a b
- Data.Unlifted: [ST#] :: forall (r :: RuntimeRep) (s :: Type) (a :: TYPE r). (State# s -> (# State# s, a #)) -> ST# s a
+ Data.Unlifted: [ST#] :: forall (r :: RuntimeRep) a (b :: TYPE r). (State# a -> (# State# a, b #)) -> ST# a b
- Data.Unlifted: newtype Either# :: forall (ra :: RuntimeRep) (rb :: RuntimeRep). TYPE ra -> TYPE rb -> TYPE ('SumRep '[ra, rb])
+ Data.Unlifted: newtype Either# (a :: TYPE ra) (b :: TYPE rb) :: TYPE 'SumRep '[ra, rb]
- Data.Unlifted: newtype IO# :: forall (r :: RuntimeRep). TYPE r -> Type
+ Data.Unlifted: newtype IO# (a :: TYPE r)
- Data.Unlifted: newtype Maybe# :: forall (r :: RuntimeRep). TYPE r -> TYPE ('SumRep '[ 'TupleRep '[], r])
+ Data.Unlifted: newtype Maybe# (a :: TYPE r) :: TYPE 'SumRep '[ZeroBitRep, r]
- Data.Unlifted: newtype MutablePrimArray# :: forall (r :: RuntimeRep). Type -> TYPE r -> TYPE ('BoxedRep 'Unlifted)
+ Data.Unlifted: newtype MutablePrimArray# a (b :: TYPE r) :: UnliftedType
- Data.Unlifted: newtype PrimArray# :: forall (r :: RuntimeRep). TYPE r -> TYPE ('BoxedRep 'Unlifted)
+ Data.Unlifted: newtype PrimArray# (a :: TYPE r) :: UnliftedType
- Data.Unlifted: newtype ST# :: forall (r :: RuntimeRep). Type -> TYPE r -> Type
+ Data.Unlifted: newtype ST# a (b :: TYPE r)
- Data.Unlifted: newtype ShortText# :: TYPE ('BoxedRep 'Unlifted)
+ Data.Unlifted: newtype ShortText# :: UnliftedType
- Data.Unlifted: newtype Text# :: TYPE ('TupleRep ['BoxedRep 'Unlifted, 'Int32Rep, 'Int32Rep])
+ Data.Unlifted: newtype Text# :: TYPE 'TupleRep '[UnliftedRep, 'Int32Rep, 'Int32Rep]
Files
- CHANGELOG.md +7/−0
- src/Data/Text/Short/Unlifted.hs +22/−8
- src/Data/Unlifted.hs +31/−2
- unlifted.cabal +2/−2
CHANGELOG.md view
@@ -1,5 +1,12 @@ # Revision history for unlifted +## 0.2.4.0 -- 2026-07-14++* Add `Show#`+* Add `equalsSingletonChar` for ShortText+* Add a type constructor `Lifted` for lifting unlifted types+* Add `Word128#`+ ## 0.2.3.0 -- 2025-04-07 * Add `IO#` and `MaybeWord16#`.
src/Data/Text/Short/Unlifted.hs view
@@ -11,20 +11,24 @@ , pattern Empty# , lift , unlift+ , equalsSingletonChar+ , null+ , toByteArray ) where -import GHC.Exts (Int#)-import Data.ByteString.Short.Internal as TS+import Prelude hiding (null)+ import Data.Text.Short (ShortText) import Data.Unlifted (ShortText# (ShortText#))-import GHC.Exts ((==#))+import GHC.Exts ((==#),Int#,Char#,ByteArray#) +import qualified Data.ByteString.Short.Internal as TS import qualified Data.Text.Short as TS import qualified Data.Text.Short.Unsafe as TS import qualified GHC.Exts as Exts pattern Empty# :: ShortText#-pattern Empty# <- (null# -> 1#)+pattern Empty# <- (null -> 1#) where Empty# = empty# (# #) @@ -32,12 +36,22 @@ empty# _ = ShortText# (Exts.runRW# (\s0 -> case Exts.newByteArray# 0# s0 of { (# s1, b #) -> case Exts.unsafeFreezeByteArray# b s1 of { (# _, y #) -> y}})) -null# :: ShortText# -> Int#-null# (ShortText# x) = Exts.sizeofByteArray# x ==# 0#+null :: ShortText# -> Int#+null (ShortText# x) = Exts.sizeofByteArray# x ==# 0# lift :: ShortText# -> ShortText-lift (ShortText# x) = TS.fromShortByteStringUnsafe (SBS x)+lift (ShortText# x) = TS.fromShortByteStringUnsafe (TS.SBS x) unlift :: ShortText -> ShortText# unlift t = case TS.toShortByteString t of- SBS x -> ShortText# x+ TS.SBS x -> ShortText# x++-- | Is the short text a single character? Only works for ascii characters.+equalsSingletonChar :: ShortText# -> Char# -> Int#+equalsSingletonChar (ShortText# t) c = case Exts.sizeofByteArray# t of+ 1# -> Exts.eqChar# (Exts.indexCharArray# t 0#) c+ _ -> 0#++toByteArray :: ShortText# -> ByteArray#+{-# inline toByteArray #-}+toByteArray (ShortText# t) = t
src/Data/Unlifted.hs view
@@ -1,9 +1,11 @@ {-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ExplicitForAll #-} {-# LANGUAGE GADTSyntax #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE PolyKinds #-}+{-# LANGUAGE StandaloneKindSignatures #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UnliftedNewtypes #-}@@ -14,7 +16,14 @@ , Either# (..) , ST# (..) , IO# (..)+ , Show# (..) + -- * Lifting Unlifted Data+ , Lifted (..)++ -- * Integral Types+ , Word128# (..)+ -- * Text , ShortText# (..) , Text# (..)@@ -30,9 +39,22 @@ ) where import Data.Kind (Type)-import GHC.Exts (RealWorld)-import GHC.Exts (ByteArray#, Int32#, Levity (Unlifted), MutableByteArray#, RuntimeRep (..), State#, TYPE, Word#)+import GHC.Exts (RealWorld, Word64#)+import GHC.Exts (ByteArray#, Int32#, Int#, Levity (Unlifted), MutableByteArray#, RuntimeRep (..), State#, TYPE, Word#)+import GHC.Int (Int(I#)) +class Show# (a :: TYPE r) where+ showsPrec# :: Int -> a -> ShowS+ show# :: a -> String++instance forall (a :: Type). Show a => Show# a where+ showsPrec# = showsPrec+ show# = show++instance Show# Int# where+ showsPrec# _ i s = shows (I# i) s+ show# i = show (I# i)+ {- | Variant of @ST@ where the argument type does not have to be lifted. This does not have a monad instance and is difficult to use. -}@@ -96,3 +118,10 @@ -} newtype Text# :: TYPE ('TupleRep ['BoxedRep 'Unlifted, 'Int32Rep, 'Int32Rep]) where Text# :: (# ByteArray#, Int32#, Int32# #) -> Text#++newtype Word128# :: TYPE ('TupleRep ['Word64Rep, 'Word64Rep]) where+ Word128# :: (# Word64#, Word64# #) -> Word128#++type Lifted :: TYPE ('BoxedRep 'Unlifted) -> Type+data Lifted (a :: TYPE ('BoxedRep 'Unlifted)) :: Type where+ Lifted :: forall (a :: TYPE ('BoxedRep 'Unlifted)). a -> Lifted a
unlifted.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: unlifted-version: 0.2.3.0+version: 0.2.4.0 synopsis: Unlifted and levity-polymorphic types description: Unlifted and levity-polymorphic variants of several types from@@ -44,4 +44,4 @@ source-repository head type: git- location: git://github.com/byteverse/unlifted.git+ location: ssh://github.com/byteverse/unlifted.git