HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebinary-0.8.9.3Haskell2010

Data.Binary.Put

The Put monad. A monad for efficiently constructing lazy bytestrings.

  • 2 types
  • 38 values
  • Packagebinary-0.8.9.3
  • Exports40
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourcePut.hs

The Put type

6 declarations
typetype Put = PutM ()
#

Put merely lifts Builder into a Writer monad, applied to ().

newtypenewtype PutM a
#

The PutM type. A Writer monad over the efficient Builder monoid.

Constructors

Instances5Monad, Functor, Applicative, Semigroup, Monoid
  • Monad PutMDefined in binary-0.8.9.3 · Data.Binary.Put
  • Functor PutMDefined in binary-0.8.9.3 · Data.Binary.Put
  • Applicative PutMDefined in binary-0.8.9.3 · Data.Binary.Put
  • Semigroup (PutM ())Defined in binary-0.8.9.3 · Data.Binary.Put
  • Monoid (PutM ())Defined in binary-0.8.9.3 · Data.Binary.Put

Flushing the implicit parse state

1 declaration
valueflush :: Put
#

Pop the ByteString we have constructed so far, if any, yielding a new chunk in the result ByteString.

Primitives

5 declarations
valueputInt8 :: Int8 -> Put
#

Efficiently write a signed byte into the output buffer

valueputByteString :: ByteString -> Put
#

An efficient primitive to write a strict ByteString into the output buffer. It flushes the current buffer, and writes the argument into a new chunk.

Big-endian primitives

8 declarations

Little-endian primitives

8 declarations

Host-endian, unaligned writes

10 declarations
valueputWordhost :: Word -> Put
#

O(1). 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.

valueputWord16host :: Word16 -> Put
#

O(1). Write a Word16 in native host order and host endianness. For portability issues see putWordhost.

valueputWord32host :: Word32 -> Put
#

O(1). Write a Word32 in native host order and host endianness. For portability issues see putWordhost.

valueputWord64host :: Word64 -> Put
#

O(1). Write a Word64 in native host order On a 32 bit machine we write two host order Word32s, in big endian form. For portability issues see putWordhost.

valueputInthost :: Int -> Put
#

O(1). 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 Int 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.

valueputInt16host :: Int16 -> Put
#

O(1). Write an Int16 in native host order and host endianness. For portability issues see putInthost.

valueputInt32host :: Int32 -> Put
#

O(1). Write an Int32 in native host order and host endianness. For portability issues see putInthost.

valueputInt64host :: Int64 -> Put
#

O(1). Write an Int64 in native host order On a 32 bit machine we write two host order Int32s, in big endian form. For portability issues see putInthost.

Unicode

2 declarations