Arithmetic of String.Pos.Raw #
This file contains basic theory about which does not actually need to know anything about strings
and therefore does not depend on Init.Data.String.Decode.
Equations
- String.instHSubRaw = { hSub := fun (p : String.Pos.Raw) (s : String) => { byteIdx := p.byteIdx - s.utf8ByteSize } }
Equations
- String.instHAddRaw = { hAdd := fun (s : String) (p : String.Pos.Raw) => { byteIdx := s.utf8ByteSize + p.byteIdx } }
Equations
- String.instHAddRaw_1 = { hAdd := fun (p : String.Pos.Raw) (s : String) => { byteIdx := p.byteIdx + s.utf8ByteSize } }
Equations
- String.instLERaw = { le := fun (p₁ p₂ : String.Pos.Raw) => p₁.byteIdx ≤ p₂.byteIdx }
Equations
- String.instLTRaw = { lt := fun (p₁ p₂ : String.Pos.Raw) => p₁.byteIdx < p₂.byteIdx }
Equations
- String.instDecidableLeRaw p₁ p₂ = inferInstanceAs (Decidable (p₁.byteIdx ≤ p₂.byteIdx))
Equations
- String.instDecidableLtRaw p₁ p₂ = inferInstanceAs (Decidable (p₁.byteIdx < p₂.byteIdx))
Returns the size of the byte slice delineated by the positions lo and hi.
Equations
- lo.byteDistance hi = hi.byteIdx - lo.byteIdx
Instances For
Accesses the indicated byte in the UTF-8 encoding of a string.
At runtime, this function is implemented by efficient, constant-time code.
Instances For
Equations
- s.getUtf8Byte p h = s.getUTF8Byte p h
Instances For
Offsets p by offset on the left. This is not an HAdd instance because it should be a
relatively rare operation, so we use a name to make accidental use less likely. To offset a position
by the size of a character character c or string s, you can use c + p resp. s + p.
This should be seen as an operation that converts relative positions into absolute positions.
See also Pos.Raw.increaseBy, which is an "advancing" operation.
Instances For
Decreases p by offset. This is not an HSub instance because it should be a relatively
rare operation, so we use a name to make accidental use less likely. To unoffset a position
by the size of a character c or string s, you can use p - c resp. p - s.
This should be seen as an operation that converts absolute positions into relative positions.
See also Pos.Raw.decreaseBy, which is an "unadvancing" operation.
Instances For
Advances p by n bytes. This is not an HAdd instance because it should be a relatively
rare operation, so we use a name to make accidental use less likely. To add the size of a
character c or string s to a raw position p, you can use p + c resp. p + s.
This should be seen as an "advance" or "skip".
See also Pos.Raw.offsetBy, which turns relative positions into absolute positions.
Instances For
Move the position p back by n bytes. This is not an HSub instance because it should be a
relatively rare operation, so we use a name to make accidental use less likely. To remove the size
of a character c or string s from a raw position p, you can use p - c resp. p - s.
This should be seen as the inverse of an "advance" or "skip".
See also Pos.Raw.unoffsetBy, which turns absolute positions into relative positions.
Instances For
Equations
- String.Pos.Raw.Internal.minImpl p₁ p₂ = p₁.min p₂