Bars

{#b}

Macro for creating ASCII bar literals.

# b {hello}    == b#hello
# b {}         == b#{}
# b {123}      == b#123

{#x}

Macro for creating hexadecimal bar literals.

# x deadbeef    == x#deadbeef
# x 00          == x#00
# x {}          == b#{}

padBar

(padBar p)
> p : Pad a
> Bar a

Converts a pad to a bar, adding zeroes to make it into whole bytes if necessary.

padBar p#11111111     == x#ff
padBar p#111111111    == x#ff01
padBar p#1            == x#01

isBar

Checks if a value is a bar (byte array).

emptyBar

Returns an empty bar.

barIsEmpty

Checks if a bar is empty.

byteWidth

Returns the number of bytes needed to represent a natural number.

barTrail

Returns the number of trailing zero bytes in a bar's internal representation.

barEnc

Encodes a natural number into a bar representation.

barDec

Decodes a bar representation back into a natural number.

mkBar

Creates a bar from a natural number and a trailing zero count.

natBar

Creates a bar from a natural number.

barNat

Converts a bar to its natural number representation.

barLen

Returns the length of a bar in bytes.

barIdx

Returns the byte at a given index in a bar.

natToSizedBar

Creates a bar of a specific size from a natural number.

barSing

Creates a bar containing a single byte.

barDuo

Creates a bar containing two bytes.

zEnd

Returns the number of trailing zero bytes in a row.

stripZEnd

Removes trailing zero bytes from a row.

w8

Converts a number to an 8-bit value (0-255).

bytesBar

Creates a bar from a row of bytes.

barGen

Generates a bar by applying a function to each index.

barRep

Creates a bar by repeating a byte value.

barGet

Gets the byte at a specific index in a bar.

barBytes

Converts a bar to a row of bytes.

barFoldl

Left-associative fold over a bar.

barFoldr

Right-associative fold over a bar.

barAny

Checks if any byte in the bar satisfies a predicate.

barAll

Checks if all bytes in the bar satisfy a predicate.

barWeld

Concatenates two bars.

barCat

Concatenates a row of bars.

barCatList

Concatenates a list of bars.

barCatMap

Maps a function over a bar and concatenates the results.

barIntercalate

Intersperses a separator bar between the elements of a row of bars.

barIntercalateList

Intersperses a separator bar between the elements of a list of bars.

barFromHex

Creates a bar from a hexadecimal string.

barPad

Returns the internal pad representation of a bar.

barTake

Takes the first n bytes from a bar.

barDrop

Drops the first n bytes from a bar.

barSlice

Takes a slice of a bar from a starting index with a given length.

barSliceToNat

Converts a slice of a bar to a natural number.

barTreeToList

Converts a tree-like structure of bars to a flat list of bars.

barFlat

Flattens a tree-like structure of bars into a single bar.

barHas

Checks if a bar contains a specific byte.

barToRow

Converts a bar to a row of bytes (alias for barBytes).

rowFromBar

Converts a bar to a row of bytes (alias for barBytes).

barToList

Converts a bar to a list of bytes.

barFromRow

Creates a bar from a row of bytes.

barFromList

Creates a bar from a list of bytes.

barFromListRev

Creates a bar from a reversed list of bytes.

rowToBar

Creates a bar from a row of bytes (alias for barFromRow).

barMap

Applies a function to each byte in a bar.

barFilter

Keeps only the bytes in a bar that satisfy a predicate.

barFindIndex

Finds the index of the first byte satisfying a predicate.

barFindIndexOff

Finds the index of the first byte satisfying a predicate, starting from an offset.

barElemIndex

Finds the index of the first occurrence of a byte.

barElemIndexOff

Finds the index of the first occurrence of a byte, starting from an offset.

barElemIndexEnd

Finds the index of the last occurrence of a byte.

barSplitAt

Splits a bar at a given index.

barSplitOne

Splits a bar at the first occurrence of a byte.

barSplitOneWith

Splits a bar at the first occurrence of a byte satisfying a predicate.

barSplitWith

Splits a bar at all occurrences of bytes satisfying a predicate.

barSplit

Splits a bar at all occurrences of a specific byte.

barCountHeadMatching

Counts the number of leading bytes until a predicate fails.

barDropWhile

Drops leading bytes from a bar while they satisfy a predicate.

barTakeWhile

Takes leading bytes from a bar while they satisfy a predicate.

hexAlphabet

A bar containing the hexadecimal digits (0-9, a-f).

hexChar

Converts a number (0-15) to its hexadecimal character representation.

byteToHex

Converts a byte to its two-character hexadecimal representation.

barToHex

Converts a bar to its hexadecimal string representation.

readBarLit

Parses a bar literal from a Rex expression.

showBarLit

Converts a bar to its Rex literal representation.

getHexBar

Parses a bar containing an ascii string as a hexadecimal number, passing the corresponding Nat to a continuation function or returning a fallback value.

barLoadDecimal

Parses a decimal number from a bar.

barShowDecimal

Converts a natural number to its decimal string representation as a bar.

barIsPrefixOf

Checks if a bar is a prefix of another bar at a given offset.

barSubstringSearch

Finds all occurrences of a substring in a bar.

barSpace

A bar containing a single space character.

Last updated