Skip to content

Commit

Permalink
Add StrictByteString & LazyByteString type aliases (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed Mar 19, 2021
1 parent f23e2d3 commit ba3046d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ ghc.mk
cabal.sandbox.config
.hsenv
*~
dist-newstyle/
3 changes: 2 additions & 1 deletion Data/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@

module Data.ByteString (

-- * The @ByteString@ type
-- * Strict @ByteString@
ByteString,
StrictByteString,

-- * Introducing and eliminating 'ByteString's
empty,
Expand Down
4 changes: 4 additions & 0 deletions Data/ByteString/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module Data.ByteString.Internal (
, PS -- backwards compatibility shim
),

StrictByteString,

-- * Internal indexing
findIndexOrLength,

Expand Down Expand Up @@ -201,6 +203,8 @@ data ByteString = BS {-# UNPACK #-} !(ForeignPtr Word8) -- payload
-- ^ @since 0.11.0.0
deriving (Typeable)

-- | Type synonym for the strict flavour of 'ByteString'.
type StrictByteString = ByteString

-- |
-- @'PS' foreignPtr offset length@ represents a 'ByteString' with data
Expand Down
3 changes: 2 additions & 1 deletion Data/ByteString/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@

module Data.ByteString.Lazy (

-- * The @ByteString@ type
-- * Lazy @ByteString@
ByteString,
LazyByteString,

-- * Introducing and eliminating 'ByteString's
empty,
Expand Down
4 changes: 4 additions & 0 deletions Data/ByteString/Lazy/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module Data.ByteString.Lazy.Internal (

-- * The lazy @ByteString@ type and representation
ByteString(..),
LazyByteString,
chunk,
foldrChunks,
foldlChunks,
Expand Down Expand Up @@ -80,6 +81,9 @@ data ByteString = Empty | Chunk {-# UNPACK #-} !S.ByteString ByteString
deriving (Typeable)
-- See 'invariant' function later in this module for internal invariants.

-- | Type synonym for the lazy flavour of 'ByteString'.
type LazyByteString = ByteString

instance Eq ByteString where
(==) = eq

Expand Down

0 comments on commit ba3046d

Please sign in to comment.