packages feed

hw-prim 0.6.2.0 → 0.6.2.2

raw patch · 5 files changed

+126/−40 lines, 5 filesdep +transformersdep ~QuickCheckdep ~bytestringdep ~criterionPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: transformers

Dependency ranges changed: QuickCheck, bytestring, criterion, directory, exceptions, hedgehog, hspec, hw-hspec-hedgehog, mmap, vector

API changes (from Hackage documentation)

- HaskellWorks.Data.Product: instance (GHC.Classes.Eq b, GHC.Classes.Eq a) => GHC.Classes.Eq (a HaskellWorks.Data.Product.:*: b)
- HaskellWorks.Data.Product: instance (GHC.Show.Show b, GHC.Show.Show a) => GHC.Show.Show (a HaskellWorks.Data.Product.:*: b)
+ HaskellWorks.Data.ByteString: class ToByteString a
+ HaskellWorks.Data.ByteString: instance HaskellWorks.Data.ByteString.ToByteString (Data.Vector.Storable.Vector GHC.Word.Word16)
+ HaskellWorks.Data.ByteString: instance HaskellWorks.Data.ByteString.ToByteString (Data.Vector.Storable.Vector GHC.Word.Word32)
+ HaskellWorks.Data.ByteString: instance HaskellWorks.Data.ByteString.ToByteString (Data.Vector.Storable.Vector GHC.Word.Word64)
+ HaskellWorks.Data.ByteString: instance HaskellWorks.Data.ByteString.ToByteString (Data.Vector.Storable.Vector GHC.Word.Word8)
+ HaskellWorks.Data.ByteString: instance HaskellWorks.Data.ByteString.ToByteString Data.ByteString.Internal.ByteString
+ HaskellWorks.Data.ByteString: toByteString :: ToByteString a => a -> ByteString
+ HaskellWorks.Data.Product: instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (a HaskellWorks.Data.Product.:*: b)
+ HaskellWorks.Data.Product: instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a HaskellWorks.Data.Product.:*: b)

Files

README.md view
@@ -1,5 +1,6 @@ # hw-prim-[![CircleCI](https://circleci.com/gh/haskell-works/hw-prim/tree/0-branch.svg?style=svg)](https://circleci.com/gh/haskell-works/hw-prim/tree/0-branch)+[![CircleCI](https://circleci.com/gh/haskell-works/hw-prim/tree/master.svg?style=svg)](https://circleci.com/gh/haskell-works/hw-prim/tree/master)+[![Travis](https://travis-ci.org/haskell-works/hw-prim.svg?branch=master)](https://travis-ci.org/haskell-works/hw-prim)  Primitive types library. 
hw-prim.cabal view
@@ -1,13 +1,11 @@--- This file has been generated from package.yaml by hpack version 0.20.0.+-- This file has been generated from package.yaml by hpack version 0.18.1. -- -- see: https://github.com/sol/hpack------ hash: 3da5a5c4ec15aafba41e3a027d8092886e0bca1ad4a9bcb85767e43bf4684b59  name:           hw-prim-version:        0.6.2.0+version:        0.6.2.2 synopsis:       Primitive functions and data types-description:    Please see README.md+description:    Primitive functions and data types. category:       Data stability:      Experimental homepage:       http://github.com/haskell-works/hw-prim#readme@@ -17,6 +15,7 @@ copyright:      2016-2018 John Ky license:        BSD3 license-file:   LICENSE+tested-with:    GHC == 8.4.2, GHC == 8.2.2, GHC == 8.0.2, GHC == 7.10.3 build-type:     Simple cabal-version:  >= 1.10 @@ -35,12 +34,14 @@ library   hs-source-dirs:       src+  other-extensions: AllowAmbiguousTypes   ghc-options: -Wall -O2 -msse4.2   build-depends:-      base >=4 && <5-    , bytestring-    , mmap-    , vector+      base >=4.8 && <5+    , bytestring >= 0.9 && < 0.11+    , mmap >= 0.5 && < 0.6+    , vector >= 0.12 && < 0.13+    , transformers >= 0.4 && < 0.6   if flag(bounds-checking-enabled)     cpp-options: -DBOUNDS_CHECKING_ENABLED   exposed-modules:@@ -73,6 +74,7 @@       HaskellWorks.Data.Vector.BoxedVectorLike       HaskellWorks.Data.Vector.StorableVectorLike   other-modules:+      HaskellWorks.Data.ByteString.Lazy       HaskellWorks.Data.Char       Paths_hw_prim   default-language: Haskell2010@@ -82,19 +84,21 @@   main-is: Spec.hs   hs-source-dirs:       test+  other-extensions: AllowAmbiguousTypes   ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N   build-depends:-      QuickCheck-    , base >=4 && <5-    , bytestring-    , directory-    , exceptions-    , hedgehog-    , hspec-    , hw-hspec-hedgehog+      base >=4.8 && <5+    , bytestring >= 0.9 && < 0.11+    , mmap >= 0.5 && < 0.6+    , vector >= 0.12 && < 0.13+    , transformers >= 0.4 && < 0.6+    , QuickCheck >= 2.10 && < 2.12+    , directory >= 1.2 && < 1.4+    , exceptions >= 0.8 && < 0.11+    , hedgehog >= 0.5 && < 0.7+    , hspec >= 2.4 && <2.6+    , hw-hspec-hedgehog >= 0.1 && < 0.2     , hw-prim-    , mmap-    , vector   if flag(bounds-checking-enabled)     cpp-options: -DBOUNDS_CHECKING_ENABLED   other-modules:@@ -102,7 +106,6 @@       HaskellWorks.Data.FromForeignRegionSpec       HaskellWorks.Data.SearchSpec       HaskellWorks.Data.Vector.AsVector64sSpec-      Paths_hw_prim   default-language: Haskell2010  benchmark bench@@ -110,16 +113,17 @@   main-is: Main.hs   hs-source-dirs:       bench+  other-extensions: AllowAmbiguousTypes   ghc-options: -Wall -O2 -msse4.2   build-depends:-      base >=4 && <5-    , bytestring-    , criterion+      base >=4.8 && <5+    , bytestring >= 0.9 && < 0.11+    , mmap >= 0.5 && < 0.6+    , vector >= 0.12 && < 0.13+    , transformers >= 0.4 && < 0.6+    , criterion >= 1.2 && < 1.5     , hw-prim-    , mmap-    , vector+    , mmap >= 0.5 && < 0.6   if flag(bounds-checking-enabled)     cpp-options: -DBOUNDS_CHECKING_ENABLED-  other-modules:-      Paths_hw_prim   default-language: Haskell2010
src/HaskellWorks/Data/ByteString.hs view
@@ -1,8 +1,41 @@+{-# LANGUAGE FlexibleInstances #-}+ module HaskellWorks.Data.ByteString   ( chunkedBy+  , ToByteString(..)   ) where -import qualified Data.ByteString as BS+import Data.Word++import qualified Data.ByteString          as BS+import qualified Data.ByteString.Internal as BSI+import qualified Data.Vector.Storable     as DVS++class ToByteString a where+  toByteString :: a -> BS.ByteString++instance ToByteString BS.ByteString where+  toByteString = id++instance ToByteString (DVS.Vector Word8) where+  toByteString v = case DVS.unsafeToForeignPtr v of+    (fptr, start, offset) -> BSI.fromForeignPtr fptr start offset+  {-# INLINE toByteString #-}++instance ToByteString (DVS.Vector Word16) where+  toByteString v = case DVS.unsafeToForeignPtr (DVS.unsafeCast v :: DVS.Vector Word8) of+    (fptr, start, offset) -> BSI.fromForeignPtr fptr start offset+  {-# INLINE toByteString #-}++instance ToByteString (DVS.Vector Word32) where+  toByteString v = case DVS.unsafeToForeignPtr (DVS.unsafeCast v :: DVS.Vector Word8) of+    (fptr, start, offset) -> BSI.fromForeignPtr fptr start offset+  {-# INLINE toByteString #-}++instance ToByteString (DVS.Vector Word64) where+  toByteString v = case DVS.unsafeToForeignPtr (DVS.unsafeCast v :: DVS.Vector Word8) of+    (fptr, start, offset) -> BSI.fromForeignPtr fptr start offset+  {-# INLINE toByteString #-}  -- | Chunk a @bs into list of smaller byte strings of no more than @n elements chunkedBy :: Int -> BS.ByteString -> [BS.ByteString]
+ src/HaskellWorks/Data/ByteString/Lazy.hs view
@@ -0,0 +1,48 @@+{-# LANGUAGE FlexibleInstances #-}++module HaskellWorks.Data.ByteString.Lazy where++import Data.Word+import HaskellWorks.Data.ByteString (ToByteString (..))++import qualified Data.ByteString.Lazy as LBS+import qualified Data.Vector.Storable as DVS++class ToLazyByteString a where+  toLazyByteString :: a -> LBS.ByteString++instance ToLazyByteString LBS.ByteString where+  toLazyByteString = id+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString (DVS.Vector Word8) where+  toLazyByteString = LBS.fromStrict . toByteString+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString (DVS.Vector Word16) where+  toLazyByteString = LBS.fromStrict . toByteString+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString (DVS.Vector Word32) where+  toLazyByteString = LBS.fromStrict . toByteString+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString (DVS.Vector Word64) where+  toLazyByteString = LBS.fromStrict . toByteString+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString [DVS.Vector Word8] where+  toLazyByteString vs = LBS.fromChunks (toByteString <$> vs)+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString [DVS.Vector Word16] where+  toLazyByteString vs = LBS.fromChunks (toByteString <$> vs)+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString [DVS.Vector Word32] where+  toLazyByteString vs = LBS.fromChunks (toByteString <$> vs)+  {-# INLINE toLazyByteString #-}++instance ToLazyByteString [DVS.Vector Word64] where+  toLazyByteString vs = LBS.fromChunks (toByteString <$> vs)+  {-# INLINE toLazyByteString #-}
src/HaskellWorks/Data/Vector/AsVector64s.hs view
@@ -8,6 +8,7 @@   ( AsVector64s(..)   ) where +import Control.Applicative ((<$>)) import Control.Monad.ST import Data.Word import Foreign.ForeignPtr@@ -32,7 +33,7 @@   {-# INLINE asVector64s #-}  bytestringsToVectors :: Int -> [BS.ByteString] -> [DVS.Vector Word64]-bytestringsToVectors n bss = go bss+bytestringsToVectors n = go   where go :: [BS.ByteString] -> [DVS.Vector Word64]         go bs = case DVS.createT (buildOneVector n bs) of           (cs, ws) -> if DVS.length ws > 0@@ -51,16 +52,15 @@   where go :: [BS.ByteString] -> DVSM.MVector s Word8 -> ST s [BS.ByteString]         go ts v = if DVSM.length v > 0           then case ts of-            (u:us) -> do-              if BS.length u <= DVSM.length v-                then case DVSM.splitAt (BS.length u) v of-                  (va, vb) -> do-                    DVSM.copy va (byteStringToVector8 u)-                    go us vb-                else case BS.splitAt (DVSM.length v) u of-                  (ua, ub) -> do-                    DVSM.copy v (byteStringToVector8 ua)-                    return (ub:us)+            (u:us) -> if BS.length u <= DVSM.length v+              then case DVSM.splitAt (BS.length u) v of+                (va, vb) -> do+                  DVSM.copy va (byteStringToVector8 u)+                  go us vb+              else case BS.splitAt (DVSM.length v) u of+                (ua, ub) -> do+                  DVSM.copy v (byteStringToVector8 ua)+                  return (ub:us)             [] -> do               DVSM.set v 0               return []