on master help sign in
Change the signature order for Foreign.getIndex
22e8ad3Adithya Kumar
benchmark/Streamly/Benchmark/Data/Array/Stream/Foreign.hs+1−1
@@ -85,7 +85,7 @@ toChunksLast inh = do
85 larr <- Stream.last s
85 larr <- Stream.last s
86 return $ case larr of
86 return $ case larr of
87 Nothing -> Nothing
87 Nothing -> Nothing
88− Just arr -> Array.getIndex arr (Array.length arr - 1)
88+ Just arr -> Array.getIndex (Array.length arr - 1) arr
89
89
90#ifdef INSPECTION
90#ifdef INSPECTION
91inspect $ hasNoTypeClasses 'toChunksLast
91inspect $ hasNoTypeClasses 'toChunksLast
src/Streamly/Internal/Data/Array/Foreign.hs+2−4
@@ -425,14 +425,12 @@ getSlicesFromLen from len =
425-- XXX Change this to a partial function instead of a Maybe type? And use
425-- XXX Change this to a partial function instead of a Maybe type? And use
426-- MA.getIndex instead.
426-- MA.getIndex instead.
427--
427--
428−-- XXX The signature should be "Int -> Array a -> Maybe a"
429−-- XXX This is a released API so make this change in the next major release.
430-- | /O(1)/ Lookup the element at the given index. Index starts from 0.
428-- | /O(1)/ Lookup the element at the given index. Index starts from 0.
431--
429--
432-- @since 0.8.0
430-- @since 0.8.0
433{-# INLINE getIndex #-}
431{-# INLINE getIndex #-}
434−getIndex :: forall a. Storable a => Array a -> Int -> Maybe a
432+getIndex :: forall a. Storable a => Int -> Array a -> Maybe a
435−getIndex arr i =
433+getIndex i arr =
436 unsafeInlineIO
434 unsafeInlineIO
437 $ asPtrUnsafe arr
435 $ asPtrUnsafe arr
438 $ \ptr -> do
436 $ \ptr -> do
src/Streamly/Internal/FileSystem/Event/Linux.hs+2−2
@@ -658,7 +658,7 @@ ensureTrailingSlash :: Array Word8 -> Array Word8
658ensureTrailingSlash path =
658ensureTrailingSlash path =
659 if byteLength path /= 0
659 if byteLength path /= 0
660 then
660 then
661− let mx = A.getIndex path (byteLength path - 1)
661+ let mx = A.getIndex (byteLength path - 1) path
662 in case mx of
662 in case mx of
663 Nothing -> error "ensureTrailingSlash: Bug: Invalid index"
663 Nothing -> error "ensureTrailingSlash: Bug: Invalid index"
664 Just x ->
664 Just x ->
@@ -672,7 +672,7 @@ removeTrailingSlash path =
672 if byteLength path /= 0
672 if byteLength path /= 0
673 then
673 then
674 let n = byteLength path - 1
674 let n = byteLength path - 1
675− mx = A.getIndex path n
675+ mx = A.getIndex n path
676 in case mx of
676 in case mx of
677 Nothing -> error "removeTrailingSlash: Bug: Invalid index"
677 Nothing -> error "removeTrailingSlash: Bug: Invalid index"
678 Just x ->
678 Just x ->