packages feed

unlifted (empty) → 0.1.0.0

raw patch · 6 files changed

+163/−0 lines, 6 filesdep +basedep +bytestringdep +text-shortsetup-changed

Dependencies added: base, bytestring, text-short

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for unlifted++## 0.1.0.0 -- YYYY-mm-dd++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2019, Andrew Martin++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Andrew Martin nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Data/Text/Short/Unlifted.hs view
@@ -0,0 +1,25 @@+{-# language GADTSyntax #-}+{-# language KindSignatures #-}+{-# language MagicHash #-}+{-# language UnliftedNewtypes #-}++module Data.Text.Short.Unlifted+  ( ShortText#(..)+  , lift+  , unlift+  ) where+++import Data.Unlifted (ShortText#(ShortText#))+import Data.Text.Short (ShortText)+import Data.ByteString.Short.Internal as TS++import qualified Data.Text.Short as TS+import qualified Data.Text.Short.Unsafe as TS++lift :: ShortText# -> ShortText+lift (ShortText# x) = TS.fromShortByteStringUnsafe (SBS x)++unlift :: ShortText -> ShortText#+unlift t = case TS.toShortByteString t of+  SBS x -> ShortText# x
+ src/Data/Unlifted.hs view
@@ -0,0 +1,74 @@+{-# language DataKinds #-}+{-# language ExplicitForAll #-}+{-# language GADTSyntax #-}+{-# language MagicHash #-}+{-# language PatternSynonyms #-}+{-# language PolyKinds #-}+{-# language TypeApplications #-}+{-# language TypeInType #-}+{-# language UnboxedSums #-}+{-# language UnboxedTuples #-}+{-# language UnliftedNewtypes #-}++module Data.Unlifted+  ( -- * Base+    Maybe#(..)+  , Either#(..)+  , ST#(..)+    -- * Text+  , ShortText#(..)+    -- * Arrays+  , PrimArray#(..)+  , MutablePrimArray#(..)+    -- * Boolean+  , Bool#(..)+  , pattern True#+  , pattern False#+  ) where++import Data.Kind (Type)+import GHC.Exts (TYPE,State#,Levity(Unlifted),RuntimeRep(..),Int#,ByteArray#,MutableByteArray#)++-- | 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).+    { unST# :: State# s -> (# State# s, a #)+    } -> ST# s a++-- | Unboxed variant of @Bool@. This might be changed to use @Int8Rep@ in the+-- future.+newtype Bool# :: TYPE 'IntRep where+  Bool# :: Int# -> Bool#++-- | Unboxed variant of @Maybe@.+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+  Either# :: forall (ra :: RuntimeRep) (rb :: RuntimeRep) (a :: TYPE ra) (b :: TYPE rb). (# a | b #) -> Either# a b++{-# complete True#, False# #-}++pattern True# :: Bool#+pattern True# = Bool# 1#++pattern False# :: Bool#+pattern False# = Bool# 0#++-- | Mutable variant of 'PrimArray#'.+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#@+newtype PrimArray# :: forall (r :: RuntimeRep). TYPE r -> TYPE ('BoxedRep 'Unlifted) where+  PrimArray# :: forall (r :: RuntimeRep) (a :: TYPE r). ByteArray# -> PrimArray# a++-- | Unlifted variant of @ShortText@.+newtype ShortText# :: TYPE ('BoxedRep 'Unlifted) where+  ShortText# :: ByteArray# -> ShortText#
+ unlifted.cabal view
@@ -0,0 +1,27 @@+cabal-version: 2.2+name: unlifted+version: 0.1.0.0+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++library+  exposed-modules:+    Data.Unlifted+    Data.Text.Short.Unlifted+  hs-source-dirs: src+  build-depends:+    , base >=4.16 && <5+    , text-short >=0.1.5+    , bytestring >=0.11.3.1+  default-language: Haskell2010