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

Modulehex-text-0.1.0.9GHC2021

Text.Hex

  • 4 types
  • 7 values

Encoding and decoding

3 declarations
valueencodeHex :: ByteString -> Text
#

Encodes a byte string as hexadecimal number represented in text

Each byte of the input is converted into two characters in the resulting text.

Example1 expression
(encodeHex . ByteString.singleton) 192"c0"
Example1 expression
(encodeHex . ByteString.singleton) 168"a8"
Example1 expression
(encodeHex . ByteString.pack) [192, 168, 1, 2]"c0a80102"

Text produced by encodeHex can be converted back to a ByteString using decodeHex.

The lazy variant of encodeHex is lazilyEncodeHex.

The lazy variant of encodeHex

With laziness, it is possible to encode byte strings of infinite length:

Example1 expression
(LazyText.take 8 . lazilyEncodeHex . LazyByteString.pack . cycle) [1, 2, 3]"01020301"

Types

4 declarations

Type conversions

4 declarations