packages feed

hw-prim 0.5.0.3 → 0.5.0.4

raw patch · 3 files changed

+14/−6 lines, 3 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ HaskellWorks.Data.AtIndex: atIndexOrLastOr :: AtIndex v => Elem v -> v -> Position -> Elem v

Files

bench/Main.hs view
@@ -11,7 +11,6 @@ import qualified Data.ByteString          as BS import qualified Data.ByteString.Internal as BSI import qualified Data.Vector.Storable     as DVS-import qualified System.IO                as IO import qualified System.IO.MMap           as IO  setupEnvByteString :: FilePath -> IO BS.ByteString@@ -29,14 +28,12 @@ sumFileByteString :: FilePath -> IO () sumFileByteString filePath = do   !(bs :: BS.ByteString) <- mmapVectorLike filePath-  IO.hPutStrLn IO.stderr $ "Length ByteString: " <> show (BS.length bs)   let !_ = BS.foldl' (+) 0 bs   return ()  sumFileVectorWord64 :: FilePath -> IO () sumFileVectorWord64 filePath = do   !(v :: DVS.Vector Word64) <- mmapVectorLike filePath-  IO.hPutStrLn IO.stderr $ "Length Vector: " <> show (DVS.length v)   let !_ = DVS.foldl' (+) 0 v   return () 
hw-prim.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 7744d3568e3de865cd0c785d38ad2c2519a9b44316d31e88a922d3802c35aa05+-- hash: 9557d04243ece405165f6a9004bb89861952430c1af773a2563ac554b528a5f5  name:           hw-prim-version:        0.5.0.3+version:        0.5.0.4 synopsis:       Primitive functions and data types description:    Please see README.md category:       Data
src/HaskellWorks/Data/AtIndex.hs view
@@ -7,6 +7,7 @@     , AtIndex(..)     , Length(..)     , atIndexOr+    , atIndexOrLastOr     ) where  import Data.Int@@ -138,5 +139,15 @@   {-# INLINE atIndex #-}  atIndexOr :: AtIndex v => Elem v -> v -> Position -> Elem v-atIndexOr d v p = if p < fromIntegral (HW.length v) then v !!! p else d+atIndexOr d v vi = if vi >= 0 && vi < end v+  then v !!! vi+  else d {-# INLINE atIndexOr #-}++atIndexOrLastOr :: AtIndex v => Elem v -> v -> Position -> Elem v+atIndexOrLastOr d v vi = if vi >= 0 && HW.length v > 0+  then if vi < end v+    then v !!! vi+    else v !!! (end v - 1)+  else d+{-# INLINE atIndexOrLastOr #-}