Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
FintanH authored and Cole Miller committed Aug 21, 2020
1 parent e0c724e commit 32c6ed8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Data/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ index ps n
| otherwise = ps `unsafeIndex` n
{-# INLINE index #-}

-- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Nothing' if:
-- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Just' if:
--
-- > 0 <= n < length bs
--
Expand Down
2 changes: 1 addition & 1 deletion Data/ByteString/Char8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ index :: ByteString -> Int -> Char
index = (w2c .) . B.index
{-# INLINE index #-}

-- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Nothing' if:
-- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Just' if:
--
-- > 0 <= n < length bs
--
Expand Down
4 changes: 2 additions & 2 deletions Data/ByteString/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -896,15 +896,15 @@ index cs0 i = index' cs0 i
index' cs (n - fromIntegral (S.length c))
| otherwise = S.unsafeIndex c (fromIntegral n)

-- | /O(c)/ 'ByteString' index, starting from 0, that returns 'Nothing' if:
-- | /O(c)/ 'ByteString' index, starting from 0, that returns 'Just' if:
--
-- > 0 <= n < length bs
--
-- @since 0.10.10.0
indexMaybe :: ByteString -> Int64 -> Maybe Word8
indexMaybe _ i | i < 0 = Nothing
indexMaybe cs0 i = index' cs0 i
where index' Empty b = Nothing
where index' Empty _ = Nothing
index' (Chunk c cs) n
| n >= fromIntegral (S.length c) =
index' cs (n - fromIntegral (S.length c))
Expand Down
4 changes: 2 additions & 2 deletions Data/ByteString/Lazy/Char8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,14 @@ index :: ByteString -> Int64 -> Char
index = (w2c .) . L.index
{-# INLINE index #-}

-- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Nothing' if:
-- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Just' if:
--
-- > 0 <= n < length bs
--
-- @since 0.10.10.0
indexMaybe :: ByteString -> Int64 -> Maybe Char
indexMaybe = ((fmap w2c) .) . L.indexMaybe
{-# indexMaybe #-}
{-# INLINE indexMaybe #-}

-- | /O(n)/ The 'elemIndex' function returns the index of the first
-- element in the given 'ByteString' which is equal (by memchr) to the
Expand Down
2 changes: 1 addition & 1 deletion tests/Properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ prop_index_C (String8 xs) =
forAll indices $ \i -> (xs !! i) == C.pack xs `C.index` (fromIntegral i)
where indices = choose (0, length xs -1)

-- | Test 'indexMaybe for Lazy and Strict 'ByteString's.
-- | Test 'indexMaybe' for Lazy and Strict 'ByteString's.
-- If we are testing within the bounds it should return a 'Just' value.
-- If we are testing outside of the bounds it should return a 'Nothing' value.
prop_indexMaybe_Just_L xs =
Expand Down

0 comments on commit 32c6ed8

Please sign in to comment.