HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulesolana-haskell-sdk-1.3.0.0GHC2021

Network.Solana.Core.Borsh

This module provides helpers for Borsh serialization, which differs from Bincode in specific length encodings and enum tag widths. Both enforce strict 0/1 validation for Option tags and Bool encoding:

  • String lengths: Borsh uses 32-bit LE (u32), Bincode uses 64-bit LE (u64).

  • Vec counts: Borsh uses 32-bit LE (u32), Bincode uses 64-bit LE (u64).

  • Enum tags: Borsh uses 8-bit (u8), Bincode uses 32-bit LE (u32).

  • 8 values
valueputBorshString :: String -> Put
#

Serialize a String in Borsh format: u32 LE byte-length + UTF-8 bytes. The length prefix is a 32-bit little-endian word (u32).

Deserialize a String in Borsh format: u32 LE byte-length + UTF-8 bytes. Fails if the length exceeds maxBound :: Int or if the bytes are not valid UTF-8.

valuegetBorshOption :: Get a -> Get (Maybe a)
#

Deserialize a Maybe value in Borsh format: u8 tag (0 = Nothing, 1 = Just) + optional value. Fails if the tag is not 0 or 1.

valueputBorshVec :: (a -> Put) -> [a] -> Put
#

Serialize a list in Borsh format: u32 LE count + elements.

valuegetBorshVec :: Get a -> Get [a]
#

Deserialize a list in Borsh format: u32 LE count + elements. Fails if the count exceeds maxBound :: Int.

valuegetBorshBool :: Get Bool
#

Deserialize a Bool in Borsh format: u8 (0 = False, 1 = True). Fails if the byte is not 0 or 1.