Safe Haskell | None |
---|---|
Language | Haskell98 |
This module defines various utility functions used across the Network.Haskoin modules.
- bsToInteger :: ByteString -> Integer
- integerToBS :: Integer -> ByteString
- encodeHex :: ByteString -> ByteString
- decodeHex :: ByteString -> Maybe ByteString
- isLeft :: Either a b -> Bool
- isRight :: Either a b -> Bool
- fromRight :: Either a b -> b
- fromLeft :: Either a b -> a
- eitherToMaybe :: Either a b -> Maybe b
- maybeToEither :: b -> Maybe a -> Either b a
- liftEither :: Monad m => Either b a -> EitherT b m a
- liftMaybe :: Monad m => b -> Maybe a -> EitherT b m a
- decodeToMaybe :: Serialize a => ByteString -> Maybe a
- updateIndex :: Int -> [a] -> (a -> a) -> [a]
- matchTemplate :: [a] -> [b] -> (a -> b -> Bool) -> [Maybe a]
- fst3 :: (a, b, c) -> a
- snd3 :: (a, b, c) -> b
- lst3 :: (a, b, c) -> c
- modify' :: MonadState s m => (s -> s) -> m ()
- dropFieldLabel :: Int -> Options
- dropSumLabels :: Int -> Int -> String -> Options
ByteString helpers
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
encodeHex :: ByteString -> ByteString Source #
decodeHex :: ByteString -> Maybe ByteString Source #
Decode hexadecimal ByteString
. This function can fail if the string
contains invalid hexadecimal (0-9, a-f, A-F) characters
Maybe and Either monad helpers
eitherToMaybe :: Either a b -> Maybe b Source #
maybeToEither :: b -> Maybe a -> Either b a Source #
Various helpers
decodeToMaybe :: Serialize a => ByteString -> Maybe a Source #
:: Int | The index of the element to change |
-> [a] | The list of elements |
-> (a -> a) | The function to apply |
-> [a] | The result with one element changed |
Applies a function to only one element of a list defined by its index. If the index is out of the bounds of the list, the original list is returned.
:: [a] | The input list |
-> [b] | The list to serve as a template |
-> (a -> b -> Bool) | The comparison function |
-> [Maybe a] | Results of the template matching |
Use the list [b]
as a template and try to match the elements of [a]
against it. For each element of [b]
return the (first) matching element of
[a]
, or Nothing
. Output list has same size as [b]
and contains results
in same order. Elements of [a]
can only appear once.
Triples
MonadState
modify' :: MonadState s m => (s -> s) -> m () Source #
Strict evaluation of the new state
JSON Utilities
dropFieldLabel :: Int -> Options Source #