unlifted 0.2.2.0 → 0.2.3.0
raw patch · 6 files changed
+86/−1 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Monad.IO.Unlifted: [IO#] :: forall (r :: RuntimeRep) (a :: TYPE r). (State# RealWorld -> (# State# RealWorld, a #)) -> IO# a
+ Control.Monad.IO.Unlifted: lift :: IO# a -> IO a
+ Control.Monad.IO.Unlifted: newtype IO# :: forall (r :: RuntimeRep). TYPE r -> Type
+ Control.Monad.IO.Unlifted: unlift :: IO a -> IO# a
+ Data.Maybe.Word16: [MaybeWord16#] :: Word# -> MaybeWord16#
+ Data.Maybe.Word16: newtype MaybeWord16# :: TYPE 'WordRep
+ Data.Maybe.Word16: pattern JustWord16# :: Word16# -> MaybeWord16#
+ Data.Maybe.Word16: pattern NothingWord16# :: MaybeWord16#
+ Data.Text.Short.Unlifted: pattern Empty# :: ShortText#
+ Data.Unlifted: [IO#] :: forall (r :: RuntimeRep) (a :: TYPE r). (State# RealWorld -> (# State# RealWorld, a #)) -> IO# a
+ Data.Unlifted: newtype IO# :: forall (r :: RuntimeRep). TYPE r -> Type
Files
- CHANGELOG.md +4/−0
- src/Control/Monad/IO/Unlifted.hs +16/−0
- src/Data/Maybe/Word16.hs +35/−0
- src/Data/Text/Short/Unlifted.hs +19/−0
- src/Data/Unlifted.hs +9/−0
- unlifted.cabal +3/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for unlifted +## 0.2.3.0 -- 2025-04-07++* Add `IO#` and `MaybeWord16#`.+ ## 0.2.2.0 -- 2024-02-07 * Export `Text#` in `Data.Unlifted`.
+ src/Control/Monad/IO/Unlifted.hs view
@@ -0,0 +1,16 @@+{-# language MagicHash #-}++module Control.Monad.IO.Unlifted+ ( IO#(..)+ , lift+ , unlift+ ) where++import GHC.IO (IO(IO))+import Data.Unlifted (IO#(..))++lift :: IO# a -> IO a+lift (IO# f) = IO f++unlift :: IO a -> IO# a+unlift (IO f) = IO# f
+ src/Data/Maybe/Word16.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE GADTSyntax #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE UnboxedTuples #-}+{-# LANGUAGE UnliftedNewtypes #-}+{-# LANGUAGE ViewPatterns #-}++module Data.Maybe.Word16+ ( MaybeWord16# (..)+ , pattern JustWord16#+ , pattern NothingWord16#+ ) where++import GHC.Exts++-- The value 65536 is used to mean Nothing. Values above this+-- should not be used.+newtype MaybeWord16# :: TYPE 'WordRep where+ MaybeWord16# :: Word# -> MaybeWord16#++pattern JustWord16# :: Word16# -> MaybeWord16#+pattern JustWord16# a <- (helper -> (# 0#, a #))+ where+ JustWord16# w = MaybeWord16# (word16ToWord# w)++helper :: MaybeWord16# -> (# Int#, Word16# #)+{-# INLINE helper #-}+helper (MaybeWord16# x) = (# eqWord# x 65536##, wordToWord16# x #)++pattern NothingWord16# :: MaybeWord16#+pattern NothingWord16# = MaybeWord16# 65536##
src/Data/Text/Short/Unlifted.hs view
@@ -1,20 +1,39 @@ {-# LANGUAGE GADTSyntax #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnliftedNewtypes #-} module Data.Text.Short.Unlifted ( ShortText# (..)+ , pattern Empty# , lift , unlift ) where +import GHC.Exts (Int#) import Data.ByteString.Short.Internal as TS import Data.Text.Short (ShortText) import Data.Unlifted (ShortText# (ShortText#))+import GHC.Exts ((==#)) 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#)+ where+ Empty# = empty# (# #)++empty# :: (# #) -> ShortText#+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# lift :: ShortText# -> ShortText lift (ShortText# x) = TS.fromShortByteStringUnsafe (SBS x)
src/Data/Unlifted.hs view
@@ -13,6 +13,7 @@ Maybe# (..) , Either# (..) , ST# (..)+ , IO# (..) -- * Text , ShortText# (..)@@ -29,6 +30,7 @@ ) where import Data.Kind (Type)+import GHC.Exts (RealWorld) import GHC.Exts (ByteArray#, Int32#, Levity (Unlifted), MutableByteArray#, RuntimeRep (..), State#, TYPE, Word#) {- | Variant of @ST@ where the argument type does not have to be lifted.@@ -40,6 +42,13 @@ { unST# :: State# s -> (# State# s, a #) } -> ST# s a++newtype IO# :: forall (r :: RuntimeRep). TYPE r -> Type where+ IO# ::+ forall (r :: RuntimeRep) (a :: TYPE r).+ { unIO# :: State# RealWorld -> (# State# RealWorld, a #)+ } ->+ IO# a -- | Unboxed variant of @Bool@. newtype Bool# :: TYPE 'WordRep where
unlifted.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: unlifted-version: 0.2.2.0+version: 0.2.3.0 synopsis: Unlifted and levity-polymorphic types description: Unlifted and levity-polymorphic variants of several types from@@ -29,8 +29,10 @@ exposed-modules: Data.Either.Void Data.Maybe.Void+ Data.Maybe.Word16 Data.Text.Short.Unlifted Data.Unlifted+ Control.Monad.IO.Unlifted hs-source-dirs: src build-depends: