Skip to content

Commit f77759e

Browse files
authored
Add type signatures for subfunction of buildStepToCIOS (#586)
1 parent 5c4d236 commit f77759e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Data/ByteString/Builder/Internal.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,26 +1065,32 @@ toLazyByteStringWith strategy k b =
10651065
-- 'Buffer's allocated according to the given 'AllocationStrategy'.
10661066
{-# INLINE buildStepToCIOS #-}
10671067
buildStepToCIOS
1068-
:: AllocationStrategy -- ^ Buffer allocation strategy to use
1068+
:: forall a.
1069+
AllocationStrategy -- ^ Buffer allocation strategy to use
10691070
-> BuildStep a -- ^ 'BuildStep' to execute
10701071
-> IO (ChunkIOStream a)
10711072
buildStepToCIOS (AllocationStrategy nextBuffer bufSize trim) =
10721073
\step -> nextBuffer Nothing >>= fill step
10731074
where
1075+
fill :: BuildStep a -> Buffer -> IO (ChunkIOStream a)
10741076
fill !step buf@(Buffer fpbuf br@(BufferRange _ pe)) = do
10751077
res <- fillWithBuildStep step doneH fullH insertChunkH br
10761078
touchForeignPtr fpbuf
10771079
return res
10781080
where
1081+
pbuf :: Ptr Word8
10791082
pbuf = unsafeForeignPtrToPtr fpbuf
10801083

1084+
doneH :: Ptr Word8 -> a -> IO (ChunkIOStream a)
10811085
doneH op' x = return $
10821086
Finished (Buffer fpbuf (BufferRange op' pe)) x
10831087

1088+
fullH :: Ptr Word8 -> Int -> BuildStep a -> IO (ChunkIOStream a)
10841089
fullH op' minSize nextStep =
10851090
wrapChunk op' $ const $
10861091
nextBuffer (Just (buf, max minSize bufSize)) >>= fill nextStep
10871092

1093+
insertChunkH :: Ptr Word8 -> S.ByteString -> BuildStep a -> IO (ChunkIOStream a)
10881094
insertChunkH op' bs nextStep =
10891095
wrapChunk op' $ \isEmpty -> yield1 bs $
10901096
-- Checking for empty case avoids allocating 'n-1' empty
@@ -1096,6 +1102,7 @@ buildStepToCIOS (AllocationStrategy nextBuffer bufSize trim) =
10961102

10971103
-- Wrap and yield a chunk, trimming it if necesary
10981104
{-# INLINE wrapChunk #-}
1105+
wrapChunk :: Ptr Word8 -> (Bool -> IO (ChunkIOStream a)) -> IO (ChunkIOStream a)
10991106
wrapChunk !op' mkCIOS
11001107
| chunkSize == 0 = mkCIOS True
11011108
| trim chunkSize size = do

0 commit comments

Comments
 (0)