Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Byte functions.
Synopsis
- word8_to_enum :: Enum e => Word8 -> e
- enum_to_word8 :: Enum e => e -> Maybe Word8
- word8_to_char :: Word8 -> Char
- char_to_word8 :: Char -> Word8
- digit_to_word8 :: Char -> Word8
- word8_to_digit :: Word8 -> Char
- word8_at :: [t] -> Word8 -> t
- byte_hex_pp :: (Integral i, Show i) => i -> Maybe String
- byte_hex_pp_err :: (Integral i, Show i) => i -> String
- byte_seq_hex_pp :: (Integral i, Show i) => Bool -> [i] -> String
- read_hex_byte :: (Eq t, Integral t) => String -> Maybe t
- read_hex_byte_err :: (Eq t, Integral t) => String -> t
- read_hex_byte_seq :: (Eq t, Integral t) => String -> [t]
- read_hex_byte_seq_ws :: (Eq t, Integral t) => String -> [t]
- load_byte_seq :: Integral i => FilePath -> IO [i]
- store_byte_seq :: Integral i => FilePath -> [i] -> IO ()
- load_hex_byte_seq :: Integral i => FilePath -> IO [[i]]
- store_hex_byte_seq :: (Integral i, Show i) => FilePath -> [[i]] -> IO ()
- castFloatToWord32 :: Float -> Word32
- castWord32ToFloat :: Word32 -> Float
- castDoubleToWord64 :: Double -> Word64
- castWord64ToDouble :: Word64 -> Double
Enumerations & Char
word8_to_enum :: Enum e => Word8 -> e Source #
word8_to_char :: Word8 -> Char Source #
Type-specialised word8_to_enum
map word8_to_char [60,62] == "<>"
char_to_word8 :: Char -> Word8 Source #
digit_to_word8 :: Char -> Word8 Source #
word8_to_digit :: Word8 -> Char Source #
Indexing
word8_at :: [t] -> Word8 -> t Source #
at
of word8_to_int
Text
byte_hex_pp :: (Integral i, Show i) => i -> Maybe String Source #
Given n in (0,255) make two character hex string.
mapMaybe byte_hex_pp [0x0F,0xF0,0xF0F] == ["0F","F0"]
byte_seq_hex_pp :: (Integral i, Show i) => Bool -> [i] -> String Source #
byte_hex_pp_err
either plain (ws = False) or with spaces (ws = True).
Plain is the same format written by xxd -p and read by xxd -r -p.
byte_seq_hex_pp True [0x0F,0xF0] == "0F F0"
read_hex_byte :: (Eq t, Integral t) => String -> Maybe t Source #
Read two character hexadecimal string.
mapMaybe read_hex_byte (Split.chunksOf 2 "0FF0F") == [0x0F,0xF0]
read_hex_byte_seq :: (Eq t, Integral t) => String -> [t] Source #
Sequence of read_hex_byte_err
read_hex_byte_seq "000FF0FF" == [0x00,0x0F,0xF0,0xFF]
read_hex_byte_seq_ws :: (Eq t, Integral t) => String -> [t] Source #
Variant that filters white space.
read_hex_byte_seq_ws "00 0F F0 FF" == [0x00,0x0F,0xF0,0xFF]
IO
load_hex_byte_seq :: Integral i => FilePath -> IO [[i]] Source #
Load hexadecimal text U8
sequences from file.
store_hex_byte_seq :: (Integral i, Show i) => FilePath -> [[i]] -> IO () Source #
Store U8
sequences as hexadecimal text, one sequence per line.
Cast
castFloatToWord32 :: Float -> Word32 Source #
castWord32ToFloat :: Word32 -> Float Source #
castDoubleToWord64 :: Double -> Word64 Source #
castWord64ToDouble :: Word64 -> Double Source #