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

Modulererebase-1.21.2Haskell2010

Data.ByteString.Builder

  • 2 types
  • 66 values
  • Packagererebase-1.21.2
  • Exports68
  • LanguageHaskell2010
  • LicenceMIT
  • SourceRealFloat.hs
newtypenewtype Builder
#

Builders denote sequences of bytes. They are Monoids where mempty is the zero-length sequence and mappend is concatenation, which runs in O(1).

Instances6IsList, Show, IsString, Semigroup, Monoid, Item
  • IsList BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal

    For long or infinite lists use fromList because it uses LazyByteString otherwise use fromListN which uses StrictByteString.

  • Show BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder · orphan
  • IsString BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder · orphan
  • Semigroup BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • Monoid BuilderDefined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
  • type Item Builder = Word8Defined in bytestring-0.12.2.0 · Data.ByteString.Builder.Internal
valueint8Dec :: Int8 -> Builder
#

Decimal encoding of an Int8 using the ASCII digits.

e.g.

toLazyByteString (int8Dec 42)   = "42"
toLazyByteString (int8Dec (-1)) = "-1"

Returns a rendered Double. Returns the 'shortest' representation in scientific notation and takes an optional precision argument in standard notation. Also see doubleDec.

With standard notation, the precision argument is used to truncate (or extend with 0s) the 'shortest' rendered Float. The 'default precision' does no such modifications and will return as many decimal places as the representation demands.

e.g

Example5 expressions
formatDouble (standard 1) 1.2345e-2"0.0"formatDouble (standard 10) 1.2345e-2"0.0123450000"formatDouble standardDefaultPrecision 1.2345e-2"0.01234"formatDouble scientific 12.345"1.2345e1"formatDouble generic 12.345"12.345"

Returns a rendered Float. Returns the 'shortest' representation in scientific notation and takes an optional precision argument in standard notation. Also see floatDec.

With standard notation, the precision argument is used to truncate (or extend with 0s) the 'shortest' rendered Float. The 'default precision' does no such modifications and will return as many decimal places as the representation demands.

e.g

Example5 expressions
formatFloat (standard 1) 1.2345e-2"0.0"formatFloat (standard 10) 1.2345e-2"0.0123450000"formatFloat standardDefaultPrecision 1.2345e-2"0.01234"formatFloat scientific 12.345"1.2345e1"formatFloat generic 12.345"12.345"
valuehPutBuilder :: Handle -> Builder -> IO ()
#

Output a Builder to a Handle. The Builder is executed directly on the buffer of the Handle. If the buffer is too small (or not present), then it is replaced with a large enough buffer.

It is recommended that the Handle is set to binary and 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 several executions of short Builders are concatenated in the Handles buffer, therefore avoiding unnecessary buffer flushes.