hmt-base-0.20: Haskell Music Theory Base
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Byte

Description

Byte functions.

Synopsis

Enumerations & Char

word8_to_char :: Word8 -> Char Source #

Type-specialised word8_to_enum

map word8_to_char [60,62] == "<>"

Indexing

word8_at :: [t] -> Word8 -> t Source #

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_hex_pp_err :: (Integral i, Show i) => i -> String Source #

Erroring variant.

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_err :: (Eq t, Integral t) => String -> t Source #

Erroring variant.

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_byte_seq :: Integral i => FilePath -> IO [i] Source #

Load binary U8 sequence from file.

store_byte_seq :: Integral i => FilePath -> [i] -> IO () Source #

Store binary U8 sequence to file.

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