Skip to content

Commit 5b7d826

Browse files
committed
Add hPut
1 parent de397ae commit 5b7d826

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Note: Prior to version 0.3.4.0, this library was named
55
`small-bytearray-builder` is now just a compatibility shim
66
to ease the migration process.
77

8+
## 0.3.17.0
9+
10+
* Add `hPut` to help with common case of pushing logs to stderr.
11+
812
## 0.3.16.3
913

1014
* Add support for building with GHC 9.10

bytebuild.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: bytebuild
3-
version: 0.3.16.3
3+
version: 0.3.17.0
44
synopsis: Build byte arrays
55
description:
66
This is similar to the builder facilities provided by

src/Data/Bytes/Builder.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ module Data.Bytes.Builder
167167

168168
-- * Rebuild
169169
, rebuild
170+
171+
-- * IO
172+
, hPut
170173
) where
171174

172175
import Prelude hiding (replicate)
@@ -209,6 +212,7 @@ import GHC.Natural (naturalFromInteger, naturalToInteger)
209212
import GHC.ST (ST (ST))
210213
import GHC.Word (Word (W#), Word8 (W8#))
211214
import Numeric.Natural (Natural)
215+
import System.IO (Handle)
212216

213217
import qualified Compat as C
214218

@@ -217,6 +221,7 @@ import qualified Arithmetic.Types as Arithmetic
217221
import qualified Data.Bytes as Bytes
218222
import qualified Data.Bytes.Builder.Bounded as Bounded
219223
import qualified Data.Bytes.Builder.Bounded.Unsafe as UnsafeBounded
224+
import qualified Data.Bytes.Chunks as Chunks
220225
import qualified Data.Primitive as PM
221226
import qualified Data.Text.Short as TS
222227
import qualified GHC.Exts as Exts
@@ -1557,3 +1562,7 @@ rebuild :: Builder -> Builder
15571562
{-# INLINE rebuild #-}
15581563
rebuild (Builder f) = Builder $ oneShot $ \a -> oneShot $ \b -> oneShot $ \c -> oneShot $ \d -> oneShot $ \e ->
15591564
f a b c d e
1565+
1566+
hPut :: Handle -> Builder -> IO ()
1567+
{-# NOINLINE hPut #-}
1568+
hPut h = Chunks.hPut h . run 256

0 commit comments

Comments
 (0)