Skip to content

Commit

Permalink
Fix all missing Haddock links
Browse files Browse the repository at this point in the history
  • Loading branch information
fumieval committed Jul 6, 2020
1 parent e6bcf86 commit 22a5be7
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Data/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ foldr' k v (PS fp off len) =
{-# INLINE foldr' #-}

-- | 'foldl1' is a variant of 'foldl' that has no starting value
-- argument, and thus must be applied to non-empty 'ByteStrings'.
-- argument, and thus must be applied to non-empty 'ByteString's.
-- An exception will be thrown in the case of an empty ByteString.
foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
foldl1 f ps
Expand Down Expand Up @@ -1009,7 +1009,7 @@ splitWith pred_ (PS fp off len) = splitWith0 pred# off len fp
-- > split == splitWith . (==)
--
-- As for all splitting functions in this library, this function does
-- not copy the substrings, it just constructs new 'ByteStrings' that
-- not copy the substrings, it just constructs new 'ByteString's that
-- are slices of the original.
--
split :: Word8 -> ByteString -> [ByteString]
Expand Down
15 changes: 8 additions & 7 deletions Data/ByteString/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ infixr 4 \<\>
@
CSV is a character-based representation of tables. For maximal modularity,
we could first render 'Table's as 'String's and then encode this 'String'
we could first render @Table@s as 'String's and then encode this 'String'
using some Unicode character encoding. However, this sacrifices performance
due to the intermediate 'String' representation being built and thrown away
right afterwards. We get rid of this intermediate 'String' representation by
fixing the character encoding to UTF-8 and using 'Builder's to convert
'Table's directly to UTF-8 encoded CSV tables represented as lazy
@Table@s directly to UTF-8 encoded CSV tables represented as lazy
'L.ByteString's.
@
Expand Down Expand Up @@ -105,10 +105,10 @@ Note that the ASCII encoding is a subset of the UTF-8 encoding,
Using 'intDec' is more efficient than @'stringUtf8' . 'show'@,
as it avoids constructing an intermediate 'String'.
Avoiding this intermediate data structure significantly improves
performance because encoding 'Cell's is the core operation
performance because encoding @Cell@s is the core operation
for rendering CSV-tables.
See "Data.ByteString.Builder.Prim" for further
information on how to improve the performance of 'renderString'.
information on how to improve the performance of @renderString@.
We demonstrate our UTF-8 CSV encoding function on the following table.
Expand Down Expand Up @@ -149,14 +149,14 @@ Looking again at the definitions above,
we see that we took care to avoid intermediate data structures,
as otherwise we would sacrifice performance.
For example,
the following (arguably simpler) definition of 'renderRow' is about 20% slower.
the following (arguably simpler) definition of @renderRow@ is about 20% slower.
>renderRow :: Row -> Builder
>renderRow = mconcat . intersperse (charUtf8 ',') . map renderCell
Similarly, using /O(n)/ concatentations like '++' or the equivalent 'S.concat'
operations on strict and lazy 'L.ByteString's should be avoided.
The following definition of 'renderString' is also about 20% slower.
The following definition of @renderString@ is also about 20% slower.
>renderString :: String -> Builder
>renderString cs = charUtf8 $ "\"" ++ concatMap escape cs ++ "\""
Expand Down Expand Up @@ -291,7 +291,8 @@ toLazyByteString = toLazyByteStringWith
-- enough buffer.
--
-- It is recommended that the 'Handle' is set to binary and
-- 'BlockBuffering' mode. See 'hSetBinaryMode' and 'hSetBuffering'.
-- 'System.IO.BlockBuffering' mode. See 'System.IO.hSetBinaryMode' and
-- 'System.IO.hSetBuffering'.
--
-- This function is more efficient than @hPut . 'toLazyByteString'@ because in
-- many cases no buffer allocation has to be done. Moreover, the results of
Expand Down
2 changes: 1 addition & 1 deletion Data/ByteString/Builder/Extra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import Foreign
-- * an IO action for writing the Builder's data into a user-supplied memory
-- buffer.
--
-- * a pre-existing chunks of data represented by a strict 'ByteString'
-- * a pre-existing chunks of data represented by a strict 'S.ByteString'
--
-- While this is rather low level, it provides you with full flexibility in
-- how the data is written out.
Expand Down
20 changes: 11 additions & 9 deletions Data/ByteString/Builder/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ flush = builder step
--
-- 'Put's are a generalization of 'Builder's. The typical use case is the
-- implementation of an encoding that might fail (e.g., an interface to the
-- 'zlib' compression library or the conversion from Base64 encoded data to
-- <https://hackage.haskell.org/package/zlib zlib>
-- compression library or the conversion from Base64 encoded data to
-- 8-bit data). For a 'Builder', the only way to handle and report such a
-- failure is ignore it or call 'error'. In contrast, 'Put' actions are
-- expressive enough to allow reportng and handling such a failure in a pure
Expand Down Expand Up @@ -705,7 +706,7 @@ hPut h p = do
updateBufR op'
return $ fillHandle minSize nextStep
-- 'fillHandle' will flush the buffer (provided there is
-- really less than 'minSize' space left) before executing
-- really less than @minSize@ space left) before executing
-- the 'nextStep'.

insertChunkH op' bs nextStep = do
Expand Down Expand Up @@ -809,7 +810,8 @@ putToLazyByteStringWith strategy k p =
-- Raw memory
-------------

-- | Ensure that there are at least 'n' free bytes for the following 'Builder'.
-- | @'ensureFree' n@ ensures that there are at least @n@ free bytes
-- for the following 'Builder'.
{-# INLINE ensureFree #-}
ensureFree :: Int -> Builder
ensureFree minFree =
Expand Down Expand Up @@ -1013,9 +1015,9 @@ customStrategy
:: (Maybe (Buffer, Int) -> IO Buffer)
-- ^ Buffer allocation function. If 'Nothing' is given, then a new first
-- buffer should be allocated. If @'Just' (oldBuf, minSize)@ is given,
-- then a buffer with minimal size 'minSize' must be returned. The
-- strategy may reuse the 'oldBuffer', if it can guarantee that this
-- referentially transparent and 'oldBuffer' is large enough.
-- then a buffer with minimal size @minSize@ must be returned. The
-- strategy may reuse the @oldBuf@, if it can guarantee that this
-- referentially transparent and @oldBuf@ is large enough.
-> Int
-- ^ Default buffer size.
-> (Int -> Int -> Bool)
Expand Down Expand Up @@ -1067,7 +1069,7 @@ safeStrategy firstSize bufSize =
--
-- This function is inlined despite its heavy code-size to allow fusing with
-- the allocation strategy. For example, the default 'Builder' execution
-- function 'toLazyByteString' is defined as follows.
-- function 'Data.ByteString.Builder.toLazyByteString' is defined as follows.
--
-- @
-- {-\# NOINLINE toLazyByteString \#-}
Expand All @@ -1077,8 +1079,8 @@ safeStrategy firstSize bufSize =
--
-- where @L.empty@ is the zero-length lazy 'L.ByteString'.
--
-- In most cases, the parameters used by 'toLazyByteString' give good
-- performance. A sub-performing case of 'toLazyByteString' is executing short
-- In most cases, the parameters used by 'Data.ByteString.Builder.toLazyByteString' give good
-- performance. A sub-performing case of 'Data.ByteString.Builder.toLazyByteString' is executing short
-- (<128 bytes) 'Builder's. In this case, the allocation overhead for the first
-- 4kb buffer and the trimming cost dominate the cost of executing the
-- 'Builder'. You can avoid this problem using
Expand Down
9 changes: 5 additions & 4 deletions Data/ByteString/Builder/Prim/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ infixl 4 >$<
-- We can use it for example to prepend and/or append fixed values to an
-- primitive.
--
-- > import Data.ByteString.Builder.Prim as P
-- >showEncoding ((\x -> ('\'', (x, '\''))) >$< fixed3) 'x' = "'x'"
-- > where
-- > fixed3 = char7 >*< char7 >*< char7
-- > fixed3 = P.char7 >*< P.char7 >*< P.char7
--
-- Note that the rather verbose syntax for composition stems from the
-- requirement to be able to compute the size / size bound at compile time.
Expand Down Expand Up @@ -183,7 +184,7 @@ pairF (FP l1 io1) (FP l2 io2) =
-- | Change a primitives such that it first applies a function to the value
-- to be encoded.
--
-- Note that primitives are 'Contrafunctors'
-- Note that primitives are 'Contravariant'
-- <http://hackage.haskell.org/package/contravariant>. Hence, the following
-- laws hold.
--
Expand Down Expand Up @@ -248,7 +249,7 @@ runB (BP _ io) = io
-- | Change a 'BoundedPrim' such that it first applies a function to the
-- value to be encoded.
--
-- Note that 'BoundedPrim's are 'Contrafunctors'
-- Note that 'BoundedPrim's are 'Contravariant'
-- <http://hackage.haskell.org/package/contravariant>. Hence, the following
-- laws hold.
--
Expand Down Expand Up @@ -291,7 +292,7 @@ eitherB (BP b1 io1) (BP b2 io2) =
-- Unicode codepoints above 127 as follows.
--
-- @
--charASCIIDrop = 'condB' (< \'\\128\') ('fromF' 'char7') 'emptyB'
--charASCIIDrop = 'condB' (< \'\\128\') ('liftFixedToBounded' 'Data.ByteString.Builder.Prim.char7') 'emptyB'
-- @
{-# INLINE CONLIKE condB #-}
condB :: (a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
Expand Down
4 changes: 2 additions & 2 deletions Data/ByteString/Char8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ foldr' f = B.foldr' (\c a -> f (w2c c) a)
{-# INLINE foldr' #-}

-- | 'foldl1' is a variant of 'foldl' that has no starting value
-- argument, and thus must be applied to non-empty 'ByteStrings'.
-- argument, and thus must be applied to non-empty 'ByteString's.
foldl1 :: (Char -> Char -> Char) -> ByteString -> Char
foldl1 f ps = w2c (B.foldl1 (\x y -> c2w (f (w2c x) (w2c y))) ps)
{-# INLINE foldl1 #-}
Expand Down Expand Up @@ -601,7 +601,7 @@ breakEnd f = B.breakEnd (f . w2c)
-- > split == splitWith . (==)
--
-- As for all splitting functions in this library, this function does
-- not copy the substrings, it just constructs new 'ByteStrings' that
-- not copy the substrings, it just constructs new 'ByteString's that
-- are slices of the original.
--
split :: Char -> ByteString -> [ByteString]
Expand Down
8 changes: 4 additions & 4 deletions Data/ByteString/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ unsafePackLenChars len cs0 =
-- boxed string. A unboxed string literal is compiled to a static @char
-- []@ by GHC. Establishing the length of the string requires a call to
-- @strlen(3)@, so the 'Addr#' must point to a null-terminated buffer (as
-- is the case with @\"string\"\#@ literals in GHC). Use 'unsafePackAddressLen'
-- is the case with @\"string\"\#@ literals in GHC). Use 'Data.ByteString.Unsafe.unsafePackAddressLen'
-- if you know the length of the string statically.
--
-- An example:
Expand Down Expand Up @@ -443,7 +443,7 @@ createAndTrim' l f = do
memcpy p' (p `plusPtr` off) l'
return (ps, res)

-- | Wrapper of 'mallocForeignPtrBytes' with faster implementation for GHC
-- | Wrapper of 'Foreign.ForeignPtr.mallocForeignPtrBytes' with faster implementation for GHC
--
mallocByteString :: Int -> IO (ForeignPtr a)
mallocByteString = mallocPlainForeignPtrBytes
Expand Down Expand Up @@ -583,7 +583,7 @@ overflowError fun = error $ "Data.ByteString." ++ fun ++ ": size overflow"

------------------------------------------------------------------------

-- | This \"function\" has a superficial similarity to 'unsafePerformIO' but
-- | This \"function\" has a superficial similarity to 'System.IO.Unsafe.unsafePerformIO' but
-- it is in fact a malevolent agent of chaos. It unpicks the seams of reality
-- (and the 'IO' monad) so that the normal rules no longer apply. It lulls you
-- into thinking it is reasonable, but when you are not looking it stabs you
Expand Down Expand Up @@ -614,7 +614,7 @@ accursedUnutterablePerformIO (IO m) = case m realWorld# of (# _, r #) -> r
inlinePerformIO :: IO a -> a
inlinePerformIO = accursedUnutterablePerformIO
{-# INLINE inlinePerformIO #-}
{-# DEPRECATED inlinePerformIO "If you think you know what you are doing, use 'unsafePerformIO'. If you are sure you know what you are doing, use 'unsafeDupablePerformIO'. If you enjoy sharing an address space with a malevolent agent of chaos, try 'accursedUnutterablePerformIO'." #-}
{-# DEPRECATED inlinePerformIO "If you think you know what you are doing, use 'System.IO.Unsafe.unsafePerformIO'. If you are sure you know what you are doing, use 'unsafeDupablePerformIO'. If you enjoy sharing an address space with a malevolent agent of chaos, try 'accursedUnutterablePerformIO'." #-}

-- ---------------------------------------------------------------------
--
Expand Down
6 changes: 3 additions & 3 deletions Data/ByteString/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ length cs = foldlChunks (\n c -> n + fromIntegral (S.length c)) 0 cs
infixr 5 `cons`, `cons'` --same as list (:)
infixl 5 `snoc`

-- | /O(1)/ 'cons' is analogous to '(:)' for lists.
-- | /O(1)/ 'cons' is analogous to '(Prelude.:)' for lists.
--
cons :: Word8 -> ByteString -> ByteString
cons c cs = Chunk (S.singleton c) cs
Expand Down Expand Up @@ -503,7 +503,7 @@ foldr k z = foldrChunks (flip (S.foldr k)) z
{-# INLINE foldr #-}

-- | 'foldl1' is a variant of 'foldl' that has no starting value
-- argument, and thus must be applied to non-empty 'ByteStrings'.
-- argument, and thus must be applied to non-empty 'ByteString's.
foldl1 :: (Word8 -> Word8 -> Word8) -> ByteString -> Word8
foldl1 _ Empty = errorEmptyList "foldl1"
foldl1 f (Chunk c cs) = foldl f (S.unsafeHead c) (Chunk (S.unsafeTail c) cs)
Expand Down Expand Up @@ -817,7 +817,7 @@ splitWith p (Chunk c0 cs0) = comb [] (S.splitWith p c0) cs0
-- > split == splitWith . (==)
--
-- As for all splitting functions in this library, this function does
-- not copy the substrings, it just constructs new 'ByteStrings' that
-- not copy the substrings, it just constructs new 'ByteString's that
-- are slices of the original.
--
split :: Word8 -> ByteString -> [ByteString]
Expand Down
20 changes: 10 additions & 10 deletions Data/ByteString/Lazy/Char8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ module Data.ByteString.Lazy.Char8 (
) where

-- Functions transparently exported
import Data.ByteString.Lazy
import Data.ByteString.Lazy
(fromChunks, toChunks, fromStrict, toStrict
,empty,null,length,tail,init,append,reverse,transpose,cycle
,concat,take,drop,splitAt,intercalate
Expand All @@ -219,7 +219,7 @@ import Data.ByteString.Internal (w2c, c2w, isSpaceWord8)
import Data.Int (Int64)
import qualified Data.List as List

import Prelude hiding
import Prelude hiding
(reverse,head,tail,last,init,null,length,map,lines,foldl,foldr,unlines
,concat,any,take,drop,splitAt,takeWhile,dropWhile,span,break,elem,filter
,unwords,words,maximum,minimum,all,concatMap,scanl,scanl1,foldl1,foldr1
Expand All @@ -235,7 +235,7 @@ singleton :: Char -> ByteString
singleton = L.singleton . c2w
{-# INLINE singleton #-}

-- | /O(n)/ Convert a 'String' into a 'ByteString'.
-- | /O(n)/ Convert a 'String' into a 'ByteString'.
pack :: [Char] -> ByteString
pack = packChars

Expand All @@ -246,7 +246,7 @@ unpack = unpackChars
infixr 5 `cons`, `cons'` --same as list (:)
infixl 5 `snoc`

-- | /O(1)/ 'cons' is analogous to '(:)' for lists.
-- | /O(1)/ 'cons' is analogous to '(Prelude.:)' for lists.
cons :: Char -> ByteString -> ByteString
cons = L.cons . c2w
{-# INLINE cons #-}
Expand Down Expand Up @@ -332,7 +332,7 @@ foldr f = L.foldr (\c a -> f (w2c c) a)
{-# INLINE foldr #-}

-- | 'foldl1' is a variant of 'foldl' that has no starting value
-- argument, and thus must be applied to non-empty 'ByteStrings'.
-- argument, and thus must be applied to non-empty 'ByteString's.
foldl1 :: (Char -> Char -> Char) -> ByteString -> Char
foldl1 f ps = w2c (L.foldl1 (\x y -> c2w (f (w2c x) (w2c y))) ps)
{-# INLINE foldl1 #-}
Expand Down Expand Up @@ -465,7 +465,7 @@ span f = L.span (f . w2c)
-- | 'breakChar' breaks its ByteString argument at the first occurence
-- of the specified Char. It is more efficient than 'break' as it is
-- implemented with @memchr(3)@. I.e.
--
--
-- > break (=='c') "abcd" == breakChar 'c' "abcd"
--
breakChar :: Char -> ByteString -> (ByteString, ByteString)
Expand Down Expand Up @@ -493,14 +493,14 @@ spanChar = L.spanByte . c2w
-- > split '\n' "a\nb\nd\ne" == ["a","b","d","e"]
-- > split 'a' "aXaXaXa" == ["","X","X","X"]
-- > split 'x' "x" == ["",""]
--
--
-- and
--
-- > intercalate [c] . split c == id
-- > split == splitWith . (==)
--
--
-- As for all splitting functions in this library, this function does
-- not copy the substrings, it just constructs new 'ByteStrings' that
-- not copy the substrings, it just constructs new 'ByteString's that
-- are slices of the original.
--
split :: Char -> ByteString -> [ByteString]
Expand Down Expand Up @@ -658,7 +658,7 @@ zipWith f = L.zipWith ((. w2c) . f . w2c)
-- | 'lines' breaks a ByteString up into a list of ByteStrings at
-- newline Chars. The resulting strings do not contain newlines.
--
-- As of bytestring 0.9.0.3, this function is stricter than its
-- As of bytestring 0.9.0.3, this function is stricter than its
-- list cousin.
--
lines :: ByteString -> [ByteString]
Expand Down
Loading

0 comments on commit 22a5be7

Please sign in to comment.