HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleblaze-builder-0.4.4.1Haskell98

Blaze.ByteString.Builder.Word

Writes and Builders for serializing words.

Note that for serializing a three tuple (x,y,z) of bytes (or other word values) you should use the expression

fromWrite $ writeWord8 x `mappend` writeWord8 y `mappend` writeWord z

instead of

fromWord8 x `mappend` fromWord8 y `mappend` fromWord z

The first expression will result in a single atomic write of three bytes, while the second expression will check for each byte, if there is free space left in the output buffer. Coalescing these checks can improve performance quite a bit, as long as you use it sensibly.

  • 33 values

Writing words to a buffer

1 declaration

Big-endian writes

Little-endian writes

Host-endian writes

valuewriteWordhost :: Word -> Write
#

Write a single native machine Word. The Word is written in host order, host endian form, for the machine you're on. On a 64 bit machine the Word is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this way are not portable to different endian or word sized machines, without conversion.

Creating builders from words

2 declarations

We provide serialization functions both for singleton words as well as for lists of words. Using these list serialization functions is much faster than using mconcat . map fromWord<n>, as the list serialization functions use a tighter inner loop.

Big-endian serialization

Little-endian serialization

Host-endian serialization

valuefromWordhost :: Word -> Builder
#

Serialize a single native machine Word. The Word is serialized in host order, host endian form, for the machine you're on. On a 64 bit machine the Word is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this way are not portable to different endian or word sized machines, without conversion.