From 2cd5ce986c310225fb49e5bd41e152b3437c1642 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Fri, 21 Aug 2020 19:01:35 -0400 Subject: [PATCH] Implement requested changes from #146 review --- Changelog.md | 6 +++++- Data/ByteString.hs | 4 ++-- Data/ByteString/Char8.hs | 6 +++--- Data/ByteString/Lazy.hs | 4 ++-- Data/ByteString/Lazy/Char8.hs | 6 +++--- Data/ByteString/Short/Internal.hs | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Changelog.md b/Changelog.md index e708fb61e..2f0260257 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +[0.11.0.0] — + * [Add `indexMaybe` and synonym `(!?)` for indexing that returns `Maybe`](https://github.com/haskell/bytestring/pull/261) + +[0.11.0.0]: https://github.com/haskell/bytestring/compare/0.10.12.0...0.11.0.0 + [0.10.12.0] – August 2020 * **Note:** There are several breaking changes planned to be included in v0.11. @@ -9,7 +14,6 @@ * [Add `IsList` instances for strict and lazy `ByteString` and for `ShortByteString`](https://github.com/haskell/bytestring/pull/219) * [Add `createUpToN'` and `unsafeCreateUpToN'` to `Data.ByteString.Internal`](https://github.com/haskell/bytestring/pull/245) * [Add `boundedPrim` to `Data.ByteString.Builder.Prim.Internal` and deprecate `boudedPrim`](https://github.com/haskell/bytestring/pull/246) - * Add `indexMaybe` and synonym `(!?)` for indexing that returns `Maybe` * [Deprecate the `Data.ByteString.Lazy.Builder` and `Data.ByteString.Lazy.Builder.{ASCII,Extras}` modules](https://github.com/haskell/bytestring/pull/250) * [Fix documented complexity of `Data.ByteString.Lazy.length`](https://github.com/haskell/bytestring/pull/255) * [Assorted documentation fixes](https://github.com/haskell/bytestring/pull/248) diff --git a/Data/ByteString.hs b/Data/ByteString.hs index 0d24be2ea..a70d08625 100644 --- a/Data/ByteString.hs +++ b/Data/ByteString.hs @@ -1103,7 +1103,7 @@ index ps n -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 indexMaybe :: ByteString -> Int -> Maybe Word8 indexMaybe ps n | n < 0 = Nothing @@ -1115,7 +1115,7 @@ indexMaybe ps n -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 (!?) :: ByteString -> Int -> Maybe Word8 (!?) = indexMaybe {-# INLINE (!?) #-} diff --git a/Data/ByteString/Char8.hs b/Data/ByteString/Char8.hs index 2dd3d4eca..9b099d550 100644 --- a/Data/ByteString/Char8.hs +++ b/Data/ByteString/Char8.hs @@ -650,16 +650,16 @@ index = (w2c .) . B.index -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 indexMaybe :: ByteString -> Int -> Maybe Char -indexMaybe = ((fmap w2c) .) . B.indexMaybe +indexMaybe = (fmap w2c .) . B.indexMaybe {-# INLINE indexMaybe #-} -- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Just' if: -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 (!?) :: ByteString -> Int -> Maybe Char (!?) = indexMaybe {-# INLINE (!?) #-} diff --git a/Data/ByteString/Lazy.hs b/Data/ByteString/Lazy.hs index d5d62df90..ea92b0b45 100644 --- a/Data/ByteString/Lazy.hs +++ b/Data/ByteString/Lazy.hs @@ -901,7 +901,7 @@ index cs0 i = index' cs0 i -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 indexMaybe :: ByteString -> Int64 -> Maybe Word8 indexMaybe _ i | i < 0 = Nothing indexMaybe cs0 i = index' cs0 i @@ -915,7 +915,7 @@ indexMaybe cs0 i = index' cs0 i -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 (!?) :: ByteString -> Int64 -> Maybe Word8 (!?) = indexMaybe {-# INLINE (!?) #-} diff --git a/Data/ByteString/Lazy/Char8.hs b/Data/ByteString/Lazy/Char8.hs index 48f668ebe..486c3aca8 100644 --- a/Data/ByteString/Lazy/Char8.hs +++ b/Data/ByteString/Lazy/Char8.hs @@ -533,16 +533,16 @@ index = (w2c .) . L.index -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 indexMaybe :: ByteString -> Int64 -> Maybe Char -indexMaybe = ((fmap w2c) .) . L.indexMaybe +indexMaybe = (fmap w2c .) . L.indexMaybe {-# INLINE indexMaybe #-} -- | /O(1)/ 'ByteString' index, starting from 0, that returns 'Just' if: -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 (!?) :: ByteString -> Int64 -> Maybe Char (!?) = indexMaybe {-# INLINE (!?) #-} diff --git a/Data/ByteString/Short/Internal.hs b/Data/ByteString/Short/Internal.hs index 46d2b6443..11264f1fb 100644 --- a/Data/ByteString/Short/Internal.hs +++ b/Data/ByteString/Short/Internal.hs @@ -220,7 +220,7 @@ index sbs i -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 indexMaybe :: ShortByteString -> Int -> Maybe Word8 indexMaybe sbs i | i >= 0 && i < length sbs = Just $ unsafeIndex sbs i @@ -230,7 +230,7 @@ indexMaybe sbs i -- -- > 0 <= n < length bs -- --- @since 0.10.10.1 +-- @since 0.11.0.0 (!?) :: ShortByteString -> Int -> Maybe Word8 (!?) = indexMaybe