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

Modulebinary-0.8.9.3Haskell2010

Data.Binary.Get.Internal

  • 3 types
  • 19 values
  • Packagebinary-0.8.9.3
  • Exports22
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceInternal.hs

The Get type

6 declarations
newtypenewtype Get a
#
Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
  • Monad GetDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • Functor GetDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • MonadFail GetDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • Applicative GetDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • Alternative GetDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • MonadPlus GetDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
datadata Decoder a
#

A decoder produced by running a Get monad.

Constructors

  • Fail !ByteString String

    The decoder ran into an error. The decoder either used fail or was not provided enough input.

  • Partial (Maybe ByteString -> Decoder a)

    The decoder has consumed the available input and needs more to continue. Provide Just if more input is available and Nothing otherwise, and you will get a new Decoder.

  • Done !ByteString a

    The decoder has successfully finished. Except for the output value you also get the unused input.

  • BytesRead !Int64 (Int64 -> Decoder a)

    The decoder needs to know the current position in the input. Given the number of bytes remaning in the decoder, the outer decoder runner needs to calculate the position and resume the decoding.

Instances2Functor, Show
  • Functor DecoderDefined in binary-0.8.9.3 · Data.Binary.Get.Internal
  • Show a => Show (Decoder a)Defined in binary-0.8.9.3 · Data.Binary.Get.Internal
valuereadN :: Int -> (ByteString -> a) -> Get a
#

Return at least n bytes, maybe more. If not enough data is available the computation will escape with Partial.

valuereadNWith :: Int -> (Ptr a -> IO a) -> Get a
#

readNWith n f where f must be deterministic and not have side effects.

Parsing

2 declarations
valueisolate
  1. :: Int

    The number of bytes that must be consumed

  2. -> Get a

    The decoder to isolate

  3. -> Get a
#

Isolate a decoder to operate with a fixed number of bytes, and fail if fewer bytes were consumed, or more bytes were attempted to be consumed. If the given decoder fails, isolate will also fail. Offset from bytesRead will be relative to the start of isolate, not the absolute of the input.

With input chunks

6 declarations
valueensureN :: Int -> Get ()
#

Ensure that there are at least n bytes available. If not, the computation will escape with Partial.

Utility

7 declarations
valueremaining :: Get Int64
#

Deprecated. This will force all remaining input, don't use it.

DEPRECATED. Get the number of bytes of remaining input. Note that this is an expensive function to use as in order to calculate how much input remains, all input has to be read and kept in-memory. The decoder keeps the input as a strict bytestring, so you are likely better off by calculating the remaining input in another way.

valueisEmpty :: Get Bool
#

Test whether all input has been consumed, i.e. there are no remaining undecoded bytes.

valuelookAhead :: Get a -> Get a
#

Run the given decoder, but without consuming its input. If the given decoder fails, then so will this function.

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

Run the given decoder, and only consume its input if it returns Just. If Nothing is returned, the input will be unconsumed. If the given decoder fails, then so will this function.

valuelookAheadE :: Get (Either a b) -> Get (Either a b)
#

Run the given decoder, and only consume its input if it returns Right. If Left is returned, the input will be unconsumed. If the given decoder fails, then so will this function.

valuelabel :: String -> Get a -> Get a
#

Label a decoder. If the decoder fails, the label will be appended on a new line to the error message string.

ByteStrings

An efficient get method for strict ByteStrings. Fails if fewer than n bytes are left in the input. If n <= 0 then the empty string is returned.