Equations
- ByteArray.instInhabitedByteArray = { default := ByteArray.empty }
Equations
- ByteArray.instEmptyCollectionByteArray = { emptyCollection := ByteArray.empty }
@[extern lean_byte_array_push]
Equations
- ByteArray.push x✝ x = match x✝, x with | { data := bs }, b => { data := Array.push bs b }
Instances For
@[extern lean_byte_array_size]
Equations
- ByteArray.size x = match x with | { data := bs } => Array.size bs
Instances For
@[extern lean_byte_array_uget]
Equations
- ByteArray.uget x✝¹ x✝ x = match x✝¹, x✝, x with | { data := bs }, i, h => bs[i]
Instances For
@[extern lean_byte_array_get]
Equations
- ByteArray.get! x✝ x = match x✝, x with | { data := bs }, i => Array.get! bs i
Instances For
@[extern lean_byte_array_fget]
Equations
- ByteArray.get x✝ x = match x✝, x with | { data := bs }, i => Array.get bs i
Instances For
Equations
- ByteArray.instGetElemByteArrayNatUInt8LtInstLTNatSize = { getElem := fun (xs : ByteArray) (i : Nat) (h : i < ByteArray.size xs) => ByteArray.get xs { val := i, isLt := h } }
Equations
- ByteArray.instGetElemByteArrayUSizeUInt8LtNatInstLTNatValSizeValSize = { getElem := fun (xs : ByteArray) (i : USize) (h : i.val.val < ByteArray.size xs) => ByteArray.uget xs i h }
@[extern lean_byte_array_set]
Equations
- ByteArray.set! x✝¹ x✝ x = match x✝¹, x✝, x with | { data := bs }, i, b => { data := Array.set! bs i b }
Instances For
@[extern lean_byte_array_fset]
Equations
- ByteArray.set x✝¹ x✝ x = match x✝¹, x✝, x with | { data := bs }, i, b => { data := Array.set bs i b }
Instances For
@[extern lean_byte_array_uset]
def
ByteArray.uset
(a : ByteArray)
(i : USize)
:
UInt8 → USize.toNat i < ByteArray.size a → ByteArray
Equations
- ByteArray.uset x✝² x✝¹ x✝ x = match x✝², x✝¹, x✝, x with | { data := bs }, i, v, h => { data := Array.uset bs i v h }
Instances For
Equations
- ByteArray.instHashableByteArray = { hash := ByteArray.hash }
Equations
- ByteArray.isEmpty s = (ByteArray.size s == 0)
Instances For
@[extern lean_byte_array_copy_slice]
def
ByteArray.copySlice
(src : ByteArray)
(srcOff : Nat)
(dest : ByteArray)
(destOff : Nat)
(len : Nat)
(exact : optParam Bool true)
:
Copy the slice at [srcOff, srcOff + len)
in src
to [destOff, destOff + len)
in dest
, growing dest
if necessary.
If exact
is false
, the capacity will be doubled when grown.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ByteArray.extract a b e = ByteArray.copySlice a b ByteArray.empty 0 (e - b)
Instances For
Equations
- ByteArray.append a b = ByteArray.copySlice b 0 a (ByteArray.size a) (ByteArray.size b) false
Instances For
Equations
- ByteArray.instAppendByteArray = { append := ByteArray.append }
Equations
- ByteArray.toList bs = ByteArray.toList.loop bs 0 []
Instances For
@[inline]
unsafe def
ByteArray.forInUnsafe
{β : Type v}
{m : Type v → Type w}
[Monad m]
(as : ByteArray)
(b : β)
(f : UInt8 → β → m (ForInStep β))
:
m β
We claim this unsafe implementation is correct because an array cannot have more than usizeSz
elements in our runtime.
This is similar to the Array
version.
TODO: avoid code duplication in the future after we improve the compiler.
Equations
- ByteArray.forInUnsafe as b f = let sz := USize.ofNat (ByteArray.size as); ByteArray.forInUnsafe.loop as f sz 0 b
Instances For
@[implemented_by ByteArray.forInUnsafe]
def
ByteArray.forIn
{β : Type v}
{m : Type v → Type w}
[Monad m]
(as : ByteArray)
(b : β)
(f : UInt8 → β → m (ForInStep β))
:
m β
Reference implementation for forIn
Equations
- ByteArray.forIn as b f = ByteArray.forIn.loop as f (ByteArray.size as) (_ : ByteArray.size as ≤ ByteArray.size as) b
Instances For
def
ByteArray.forIn.loop
{β : Type v}
{m : Type v → Type w}
[Monad m]
(as : ByteArray)
(f : UInt8 → β → m (ForInStep β))
(i : Nat)
(h : i ≤ ByteArray.size as)
(b : β)
:
m β
Equations
- One or more equations did not get rendered due to their size.
- ByteArray.forIn.loop as f 0 x b = pure b
Instances For
@[inline]
unsafe def
ByteArray.foldlMUnsafe
{β : Type v}
{m : Type v → Type w}
[Monad m]
(f : β → UInt8 → m β)
(init : β)
(as : ByteArray)
(start : optParam Nat 0)
(stop : optParam Nat (ByteArray.size as))
:
m β
See comment at forInUnsafe
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[implemented_by ByteArray.foldlMUnsafe]
def
ByteArray.foldlM
{β : Type v}
{m : Type v → Type w}
[Monad m]
(f : β → UInt8 → m β)
(init : β)
(as : ByteArray)
(start : optParam Nat 0)
(stop : optParam Nat (ByteArray.size as))
:
m β
Reference implementation for foldlM
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[inline]
def
ByteArray.foldl
{β : Type v}
(f : β → UInt8 → β)
(init : β)
(as : ByteArray)
(start : optParam Nat 0)
(stop : optParam Nat (ByteArray.size as))
:
β
Equations
- ByteArray.foldl f init as start stop = Id.run (ByteArray.foldlM f init as start stop)
Instances For
Equations
Instances For
Equations
- List.toByteArray.loop [] x = x
- List.toByteArray.loop (b :: bs) x = List.toByteArray.loop bs (ByteArray.push x b)
Instances For
Equations
- instToStringByteArray = { toString := fun (bs : ByteArray) => List.toString (ByteArray.toList bs) }