ethereum-analyzer-deps-3.3.4: Stripped dependencies of ethereum-analyzer.

Safe HaskellSafe
LanguageHaskell98

Legacy.Haskoin.V0102.Network.Haskoin.Util

Description

This module defines various utility functions used across the Network.Haskoin modules.

Synopsis

Documentation

toStrictBS :: ByteString -> ByteString Source #

Transforms a lazy bytestring into a strict bytestring

toLazyBS :: ByteString -> ByteString Source #

Transforms a strict bytestring into a lazy bytestring

stringToBS :: String -> ByteString Source #

Transforms a string into a strict bytestring

bsToString :: ByteString -> String Source #

Transform a strict bytestring to a string

bsToInteger :: ByteString -> Integer Source #

Decode a big endian Integer from a bytestring

integerToBS :: Integer -> ByteString Source #

Encode an Integer to a bytestring as big endian

bsToHex :: ByteString -> String Source #

Encode a bytestring to a base16 (HEX) representation

hexToBS :: String -> Maybe ByteString Source #

Decode a base16 (HEX) string from a bytestring. This function can fail if the string contains invalid HEX characters

encode' :: Binary a => a -> ByteString Source #

Strict version of Data.Binary.encode

decode' :: Binary a => ByteString -> a Source #

Strict version of Data.Binary.decode

runPut' :: Put -> ByteString Source #

Strict version of Data.Binary.runPut

runGet' :: Binary a => Get a -> ByteString -> a Source #

Strict version of Data.Binary.runGet

decodeOrFail' :: Binary a => ByteString -> Either (ByteString, ByteOffset, String) (ByteString, ByteOffset, a) Source #

Strict version of Data.Binary.decodeOrFail

runGetOrFail' :: Binary a => Get a -> ByteString -> Either (ByteString, ByteOffset, String) (ByteString, ByteOffset, a) Source #

Strict version of Data.Binary.runGetOrFail

fromDecode Source #

Arguments

:: Binary a 
=> ByteString

The bytestring to decode

-> b

Default value to return when decoding fails

-> (a -> b)

Function to apply when decoding succeeds

-> b

Final result

Try to decode a Data.Binary value. If decoding succeeds, apply the function to the result. Otherwise, return the default value.

fromRunGet Source #

Arguments

:: Binary a 
=> Get a

The Get monad to run

-> ByteString

The bytestring to decode

-> b

Default value to return when decoding fails

-> (a -> b)

Function to apply when decoding succeeds

-> b

Final result

Try to run a Data.Binary.Get monad. If decoding succeeds, apply a function to the result. Otherwise, return the default value.

decodeToEither :: Binary a => ByteString -> Either String a Source #

Decode a Data.Binary value into the Either monad. A Right value is returned with the result upon success. Otherwise a Left value with the error message is returned.

decodeToMaybe :: Binary a => ByteString -> Maybe a Source #

Decode a Data.Binary value into the Maybe monad. A Just value is returned with the result upon success. Otherwise, Nothing is returned.

isolate :: Binary a => Int -> Get a -> Get a Source #

Isolate a Data.Binary.Get monad for the next Int bytes. Only the next Int bytes of the input bytestring will be available for the Get monad to consume. This function will fail if the Get monad fails or some of the input is not consumed.