unlifted 0.2.1.0 → 0.2.1.1
raw patch · 8 files changed
+160/−120 lines, 8 filessetup-changednew-uploaderPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +8/−2
- README.md +6/−0
- Setup.hs +0/−2
- src/Data/Either/Void.hs +35/−28
- src/Data/Maybe/Void.hs +27/−23
- src/Data/Text/Short/Unlifted.hs +7/−8
- src/Data/Unlifted.hs +43/−37
- unlifted.cabal +34/−20
CHANGELOG.md view
@@ -1,9 +1,15 @@ # Revision history for unlifted +## 0.2.1.1 -- 2024-02-06++* Update package metadata.++## 0.2.1.0 -- 2023-08-31+ ## 0.2.0.0 -- 2023-08-22 * Add `Text#`. Change `Bool#` to use `Word#` instead of `Int#`. -## 0.1.0.0 -- YYYY-mm-dd+## 0.1.0.0 -- 2023-05-31 -* First version. Released on an unsuspecting world.+* First version.
+ README.md view
@@ -0,0 +1,6 @@+# unlifted++Sadly, the library cannot define types like `Maybe#` because of+[GHC issue #17178](https://gitlab.haskell.org/ghc/ghc/issues/17178).+However, there are other fun things like `Bool#` and `ShortText#`+that we are able to provide. This is intended for use with `vext`.
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
src/Data/Either/Void.hs view
@@ -1,50 +1,57 @@-{-# language DataKinds #-}-{-# language ScopedTypeVariables #-}-{-# language ViewPatterns #-}-{-# language RankNTypes #-}-{-# language KindSignatures #-}-{-# language PatternSynonyms #-}-{-# language MagicHash #-}-{-# language GADTSyntax #-}-{-# language UnliftedNewtypes #-}-{-# language UnboxedTuples #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE GADTSyntax #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE UnboxedTuples #-}+{-# LANGUAGE UnliftedNewtypes #-}+{-# LANGUAGE ViewPatterns #-} module Data.Either.Void- ( EitherVoid#(..)+ ( EitherVoid# (..) , pattern LeftVoid# , pattern RightVoid# ) where import GHC.Exts --- | Unboxed variant of @Either@. The thing possibly contained by @Just@--- has a void runtime representation. Rather than using a sum, like the--- more general @Either#@ does, this represents @Left@ with 0 and--- @Right@ with 1.------ It is recommended that the data constructor not be used directly.--- Prefer the two pattern synonyms.+{- | Unboxed variant of @Either@. The thing possibly contained by @Just@+has a void runtime representation. Rather than using a sum, like the+more general @Either#@ does, this represents @Left@ with 0 and+@Right@ with 1.++It is recommended that the data constructor not be used directly.+Prefer the two pattern synonyms.+-} newtype EitherVoid# :: TYPE ('TupleRep '[]) -> TYPE ('TupleRep '[]) -> TYPE 'WordRep where EitherVoid# :: forall (a :: TYPE ('TupleRep '[])) (b :: TYPE ('TupleRep '[])). Word# -> EitherVoid# a b {-# COMPLETE RightVoid#, LeftVoid# #-} pattern RightVoid# :: b -> EitherVoid# a b-pattern RightVoid# a <- (helperRight -> (# 1##, a #)) where- RightVoid# _ = EitherVoid# 1##+pattern RightVoid# a <- (helperRight -> (# 1##, a #))+ where+ RightVoid# _ = EitherVoid# 1## -helperRight :: forall (a :: TYPE ('TupleRep '[])) (b :: TYPE ('TupleRep '[])).- EitherVoid# a b -> (# Word#, b #)-{-# inline helperRight #-}+helperRight ::+ forall (a :: TYPE ('TupleRep '[])) (b :: TYPE ('TupleRep '[])).+ EitherVoid# a b ->+ (# Word#, b #)+{-# INLINE helperRight #-} helperRight (EitherVoid# x) = (# x, (unsafeCoerce# :: (# #) -> b) (# #) #) pattern LeftVoid# :: a -> EitherVoid# a b-pattern LeftVoid# a <- (helperLeft -> (# 0##, a #)) where- LeftVoid# _ = EitherVoid# 0##+pattern LeftVoid# a <- (helperLeft -> (# 0##, a #))+ where+ LeftVoid# _ = EitherVoid# 0## -helperLeft :: forall (a :: TYPE ('TupleRep '[])) (b :: TYPE ('TupleRep '[])).- EitherVoid# a b -> (# Word#, a #)-{-# inline helperLeft #-}+helperLeft ::+ forall (a :: TYPE ('TupleRep '[])) (b :: TYPE ('TupleRep '[])).+ EitherVoid# a b ->+ (# Word#, a #)+{-# INLINE helperLeft #-} helperLeft (EitherVoid# x) = (# x, (unsafeCoerce# :: (# #) -> a) (# #) #)
src/Data/Maybe/Void.hs view
@@ -1,39 +1,43 @@-{-# language DataKinds #-}-{-# language ScopedTypeVariables #-}-{-# language ViewPatterns #-}-{-# language RankNTypes #-}-{-# language KindSignatures #-}-{-# language PatternSynonyms #-}-{-# language MagicHash #-}-{-# language GADTSyntax #-}-{-# language UnliftedNewtypes #-}-{-# language UnboxedTuples #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE GADTSyntax #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE UnboxedTuples #-}+{-# LANGUAGE UnliftedNewtypes #-}+{-# LANGUAGE ViewPatterns #-} module Data.Maybe.Void- ( MaybeVoid#(..)+ ( MaybeVoid# (..) , pattern JustVoid# , pattern NothingVoid# ) where import GHC.Exts --- | Unboxed variant of @Maybe@. The thing possibly contained by @Just@--- has a void runtime representation. Rather than using a sum, like the--- more general @Maybe#@ does, this represents @Nothing@ with 0 and--- @Just@ with 1.------ It is recommended that the data constructor not be used directly.--- Prefer the two pattern synonyms.+{- | Unboxed variant of @Maybe@. The thing possibly contained by @Just@+has a void runtime representation. Rather than using a sum, like the+more general @Maybe#@ does, this represents @Nothing@ with 0 and+@Just@ with 1.++It is recommended that the data constructor not be used directly.+Prefer the two pattern synonyms.+-} newtype MaybeVoid# :: TYPE ('TupleRep '[]) -> TYPE 'WordRep where MaybeVoid# :: forall (a :: TYPE ('TupleRep '[])). Word# -> MaybeVoid# a pattern JustVoid# :: a -> MaybeVoid# a-pattern JustVoid# a <- (helper -> (# 1##, a #)) where- JustVoid# _ = MaybeVoid# 1##+pattern JustVoid# a <- (helper -> (# 1##, a #))+ where+ JustVoid# _ = MaybeVoid# 1## -helper :: forall (a :: TYPE ('TupleRep '[])).- MaybeVoid# a -> (# Word#, a #)-{-# inline helper #-}+helper ::+ forall (a :: TYPE ('TupleRep '[])).+ MaybeVoid# a ->+ (# Word#, a #)+{-# INLINE helper #-} helper (MaybeVoid# x) = (# x, (unsafeCoerce# :: (# #) -> a) (# #) #)
src/Data/Text/Short/Unlifted.hs view
@@ -1,18 +1,17 @@-{-# language GADTSyntax #-}-{-# language KindSignatures #-}-{-# language MagicHash #-}-{-# language UnliftedNewtypes #-}+{-# LANGUAGE GADTSyntax #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE UnliftedNewtypes #-} module Data.Text.Short.Unlifted- ( ShortText#(..)+ ( ShortText# (..) , lift , unlift ) where --import Data.Unlifted (ShortText#(ShortText#))-import Data.Text.Short (ShortText) import Data.ByteString.Short.Internal as TS+import Data.Text.Short (ShortText)+import Data.Unlifted (ShortText# (ShortText#)) import qualified Data.Text.Short as TS import qualified Data.Text.Short.Unsafe as TS
src/Data/Unlifted.hs view
@@ -1,54 +1,58 @@-{-# language DataKinds #-}-{-# language ExplicitForAll #-}-{-# language GADTSyntax #-}-{-# language MagicHash #-}-{-# language PatternSynonyms #-}-{-# language PolyKinds #-}-{-# language TypeApplications #-}-{-# language TypeInType #-}-{-# language UnboxedSums #-}-{-# language UnboxedTuples #-}-{-# language UnliftedNewtypes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ExplicitForAll #-}+{-# LANGUAGE GADTSyntax #-}+{-# LANGUAGE MagicHash #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE UnboxedTuples #-}+{-# LANGUAGE UnliftedNewtypes #-} module Data.Unlifted ( -- * Base- Maybe#(..)- , Either#(..)- , ST#(..)+ Maybe# (..)+ , Either# (..)+ , ST# (..)+ -- * Text- , ShortText#(..)+ , ShortText# (..)+ -- * Arrays- , PrimArray#(..)- , MutablePrimArray#(..)+ , PrimArray# (..)+ , MutablePrimArray# (..)+ -- * Boolean- , Bool#(..)+ , Bool# (..) , pattern True# , pattern False# ) where import Data.Kind (Type)-import GHC.Exts (TYPE,State#,Levity(Unlifted),RuntimeRep(..),Int#,ByteArray#,MutableByteArray#,Word#,Int32#)+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.--- This does not have a monad instance and is difficult to use.+{- | 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.+-} newtype ST# :: forall (r :: RuntimeRep). Type -> TYPE r -> Type where- ST# :: forall (r :: RuntimeRep) (s :: Type) (a :: TYPE r).+ ST# ::+ forall (r :: RuntimeRep) (s :: Type) (a :: TYPE r). { unST# :: State# s -> (# State# s, a #)- } -> ST# s a+ } ->+ ST# s a -- | Unboxed variant of @Bool@. newtype Bool# :: TYPE 'WordRep where Bool# :: Word# -> Bool# -- | Unboxed variant of @Maybe@.-newtype Maybe# :: forall (r :: RuntimeRep). TYPE r -> TYPE ('SumRep '[ 'TupleRep '[], r ]) where+newtype Maybe# :: forall (r :: RuntimeRep). TYPE r -> TYPE ('SumRep '[ 'TupleRep '[], r]) where Maybe# :: forall (r :: RuntimeRep) (a :: TYPE r). (# (# #) | a #) -> Maybe# @r a -- | Unboxed variant of @Either@.-newtype Either# :: forall (ra :: RuntimeRep) (rb :: RuntimeRep). TYPE ra -> TYPE rb -> TYPE ('SumRep '[ ra, rb ]) where+newtype Either# :: forall (ra :: RuntimeRep) (rb :: RuntimeRep). TYPE ra -> TYPE rb -> TYPE ('SumRep '[ra, rb]) where Either# :: forall (ra :: RuntimeRep) (rb :: RuntimeRep) (a :: TYPE ra) (b :: TYPE rb). (# a | b #) -> Either# a b -{-# complete True#, False# #-}+{-# COMPLETE True#, False# #-} pattern True# :: Bool# pattern True# = Bool# 1##@@ -60,11 +64,12 @@ newtype MutablePrimArray# :: forall (r :: RuntimeRep). Type -> TYPE r -> TYPE ('BoxedRep 'Unlifted) where MutablePrimArray# :: forall (r :: RuntimeRep) (s :: Type) (a :: TYPE r). MutableByteArray# s -> MutablePrimArray# s a --- | This resembles the @PrimArray@ type from @primitive@, but the phantom--- parameter is an unboxed type, not a lifted type. For example:------ * @PrimArray Word8@--- * @PrimArray# Word8#@+{- | This resembles the @PrimArray@ type from @primitive@, but the phantom+parameter is an unboxed type, not a lifted type. For example:++* @PrimArray Word8@+* @PrimArray# Word8#@+-} newtype PrimArray# :: forall (r :: RuntimeRep). TYPE r -> TYPE ('BoxedRep 'Unlifted) where PrimArray# :: forall (r :: RuntimeRep) (a :: TYPE r). ByteArray# -> PrimArray# a @@ -72,11 +77,12 @@ newtype ShortText# :: TYPE ('BoxedRep 'Unlifted) where ShortText# :: ByteArray# -> ShortText# --- | Unboxed variant of @Text@. This includes a somewhat dubious restriction--- that on the offset and length that prevents byte arrays larger than 2GiB--- from being used as the backing store.------ This decision makes the type work well in the vext library, and it makes--- the in-memory format close to what Apache Arrow uses. +{- | Unboxed variant of @Text@. This includes a somewhat dubious restriction+that on the offset and length that prevents byte arrays larger than 2GiB+from being used as the backing store.++This decision makes the type work well in the vext library, and it makes+the in-memory format close to what Apache Arrow uses.+-} newtype Text# :: TYPE ('TupleRep ['BoxedRep 'Unlifted, 'Int32Rep, 'Int32Rep]) where Text# :: (# ByteArray#, Int32#, Int32# #) -> Text#
unlifted.cabal view
@@ -1,29 +1,43 @@-cabal-version: 2.2-name: unlifted-version: 0.2.1.0-synopsis: Unlifted and levity-polymorphic types+cabal-version: 2.4+name: unlifted+version: 0.2.1.1+synopsis: Unlifted and levity-polymorphic types description: Unlifted and levity-polymorphic variants of several types from `base`.-homepage: https://github.com/andrewthad/unlifted-bug-reports: https://github.com/andrewthad/unlifted/issues-license: BSD-3-Clause-license-file: LICENSE-author: Andrew Martin-maintainer: andrew.thaddeus@gmail.com-copyright: 2019 Andrew Martin-category: Data-extra-source-files: CHANGELOG.md +homepage: https://github.com/byteverse/unlifted+bug-reports: https://github.com/byteverse/unlifted/issues+license: BSD-3-Clause+license-file: LICENSE+author: Andrew Martin+maintainer: amartin@layer3com.com+copyright: 2019 Andrew Martin+category: Data+extra-doc-files:+ CHANGELOG.md+ README.md++common build-settings+ default-language: Haskell2010+ ghc-options: -Wall -Wunused-packages+ library+ import: build-settings exposed-modules:- Data.Unlifted- Data.Text.Short.Unlifted Data.Either.Void Data.Maybe.Void- hs-source-dirs: src+ Data.Text.Short.Unlifted+ Data.Unlifted++ hs-source-dirs: src build-depends:- , base >=4.16 && <5- , text-short >=0.1.5- , bytestring >=0.11.3.1- default-language: Haskell2010+ , base >=4.16 && <5+ , bytestring >=0.11.3.1+ , text-short >=0.1.5++ ghc-options: -O2++source-repository head+ type: git+ location: git://github.com/byteverse/unlifted.git