Strings #
This file builds on the UTF-8 verification in Init.Data.String.Decode and the preliminary
material in Init.Data.String.Defs to get the theory of strings off the ground. In particular,
in this file we construct the decoding function String.data : String → List Char and show that
it is a two-sided inverse to List.asString : List Char → String. This in turn enables us to
understand the validity predicate on positions in terms of lists of characters, which forms the
basis for all further verification for strings.
Decodes a sequence of characters from their UTF-8 representation. Returns none if the bytes are
not a sequence of Unicode scalar values.
Equations
- b.utf8Decode? = ByteArray.utf8Decode?.go b (b.size + 1) 0 #[] ⋯ ⋯
Instances For
Equations
- b.validateUTF8 = ByteArray.validateUTF8.go b (b.size + 1) 0 ⋯ ⋯
Instances For
Equations
Decodes an array of bytes that encode a string as UTF-8 into
the corresponding string, or returns none if the array is not a valid UTF-8 encoding of a string.
Equations
- String.fromUTF8? a = if h : a.IsValidUTF8 then some (String.fromUTF8 a h) else none
Instances For
Decodes an array of bytes that encode a string as UTF-8 into the corresponding string, or panics if the array is not a valid UTF-8 encoding of a string.
Equations
- String.fromUTF8! a = if h : a.IsValidUTF8 then String.fromUTF8 a h else panicWithPosWithDecl "Init.Data.String.Basic" "String.fromUTF8!" 212 46 "invalid UTF-8 string"
Instances For
Equations
Instances For
Converts a string to a list of characters.
Since strings are represented as dynamic arrays of bytes containing the string encoded using UTF-8, this operation takes time and space linear in the length of the string.
Examples:
Equations
- s.toList = (String.Internal.toArray s).toList
Instances For
Converts a string to a list of characters.
Since strings are represented as dynamic arrays of bytes containing the string encoded using UTF-8, this operation takes time and space linear in the length of the string.
Examples:
Equations
- b.data = (String.Internal.toArray b).toList
Instances For
Equations
- s₁.decidableLT s₂ = s₁.toList.decidableLT s₂.toList
Returns true if p is a valid UTF-8 position in the string s.
This means that p ≤ s.rawEndPos and p lies on a UTF-8 character boundary. At runtime, this
operation takes constant time.
Examples:
String.Pos.isValid "abc" ⟨0⟩ = trueString.Pos.isValid "abc" ⟨1⟩ = trueString.Pos.isValid "abc" ⟨3⟩ = trueString.Pos.isValid "abc" ⟨4⟩ = falseString.Pos.isValid "𝒫(A)" ⟨0⟩ = trueString.Pos.isValid "𝒫(A)" ⟨1⟩ = falseString.Pos.isValid "𝒫(A)" ⟨2⟩ = falseString.Pos.isValid "𝒫(A)" ⟨3⟩ = falseString.Pos.isValid "𝒫(A)" ⟨4⟩ = true
Equations
- String.Pos.Raw.isValid s p = if h : p < s.rawEndPos then decide (s.getUTF8Byte p h).IsUTF8FirstByte else decide (p = s.rawEndPos)
Instances For
Equations
Creates a String from a String.Slice by copying the bytes.
Equations
- s.copy = s.startInclusive.extract s.endExclusive
Instances For
Efficiently checks whether a position is at a UTF-8 character boundary of the slice s.
Equations
- String.Pos.Raw.isValidForSlice s p = if h : p < s.rawEndPos then decide (s.getUTF8Byte p h).IsUTF8FirstByte else decide (p = s.rawEndPos)
Instances For
Equations
Given a slice and a valid position within the slice, obtain a new slice on the same underlying string by replacing the start of the slice with the given position.
Equations
- s.replaceStart pos = { str := s.str, startInclusive := pos.str, endExclusive := s.endExclusive, startInclusive_le_endExclusive := ⋯ }
Instances For
Given a slice and a valid position within the slice, obtain a new slice on the same underlying string by replacing the end of the slice with the given position.
Equations
- s.replaceEnd pos = { str := s.str, startInclusive := s.startInclusive, endExclusive := pos.str, startInclusive_le_endExclusive := ⋯ }
Instances For
Given a slice and two valid positions within the slice, obtain a new slice on the same underlying string formed by the new bounds, or panic if the given end is strictly less than the given start.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- s.decodeChar byteIdx h = s.bytes.utf8DecodeChar byteIdx h
Instances For
Returns the byte at the given position in the string, or panicks if the position is the end position.
Equations
Instances For
Returns the character at the position pos of a string, taking a proof that p is not the
past-the-end position.
This function is overridden with an efficient implementation in runtime code.
Examples:
("abc".pos ⟨1⟩ (by decide)).get (by decide) = 'b'("L∃∀N".pos ⟨1⟩ (by decide)).get (by decide) = '∃'
Instances For
Returns the character at the position pos of a string, or none if the position is the
past-the-end position.
This function is overridden with an efficient implementation in runtime code.
Instances For
Returns the character at the position pos of a string, or panics if the position is the
past-the-end position.
This function is overridden with an efficient implementation in runtime code.
Instances For
Given a position in s.replaceStart p₀, obtain the corresponding position in s.
Equations
Instances For
Given a position in s that is at least p₀, obtain the corresponding position in
s.replaceStart p₀.
Equations
- p₀.toReplaceStart pos h = { offset := pos.offset.unoffsetBy p₀.offset, isValidForSlice := ⋯ }
Instances For
Given a position in s.replaceEnd p₀, obtain the corresponding position in s.
Equations
- String.Slice.Pos.ofReplaceEnd pos = { offset := pos.offset, isValidForSlice := ⋯ }
Instances For
Given a position in s that is at most p₀, obtain the corresponding position in s.replaceEnd p₀.
Equations
- p₀.toReplaceEnd pos h = { offset := pos.offset, isValidForSlice := ⋯ }
Instances For
Advances a valid position on a slice to the next valid position, given a proof that the position is not the past-the-end position, which guarantees that such a position exists.
Equations
- pos.next h = { offset := pos.offset.increaseBy ((pos.byte h).utf8ByteSize ⋯), isValidForSlice := ⋯ }
Instances For
Advances a valid position on a slice to the next valid position, or panics if the given position is the past-the-end position.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the previous valid position before the given position, given a proof that the position is not the start position, which guarantees that such a position exists.
Instances For
Returns the previous valid position before the given position, or panics if the position is the start position.
Equations
Instances For
Constructs a valid position on s from a position and a proof that it is valid.
Instances For
Constructs a valid position s from a position, panicking if the position is not valid.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Advances a valid position on a string to the next valid position, given a proof that the position is not the past-the-end position, which guarantees that such a position exists.
Instances For
Advances a valid position on a string to the next valid position, or returns none if the
given position is the past-the-end position.
Equations
- pos.next? = Option.map String.Slice.Pos.ofSlice pos.toSlice.next?
Instances For
Returns the previous valid position before the given position, given a proof that the position is not the start position, which guarantees that such a position exists.
Instances For
Returns the previous valid position before the given position, or none if the position is
the start position.
Equations
- pos.prev? = Option.map String.Slice.Pos.ofSlice pos.toSlice.prev?
Instances For
Constructs a valid position on s from a position, returning none if the position is not valid.
Equations
- s.pos? off = Option.map String.Slice.Pos.ofSlice (s.toSlice.pos? off)
Instances For
Given a byte position within a string slice, obtains the smallest valid position that is strictly greater than the given byte position.
Equations
- String.Slice.findNextPos offset s _h = String.Slice.findNextPos.go✝ s offset.inc
Instances For
Equations
Instances For
Returns the character at position p of a string. If p is not a valid position, returns the
fallback value (default : Char), which is 'A', but does not panic.
This function is overridden with an efficient implementation in runtime code. See
String.Pos.Raw.utf8GetAux for the reference implementation.
This is a legacy function. The recommended alternative is String.ValidPos.get, combined with
String.pos or another means of obtaining a String.ValidPos.
Examples:
"abc".get ⟨1⟩ = 'b'"abc".get ⟨3⟩ = (default : Char)because byte3is at the end of the string."L∃∀N".get ⟨2⟩ = (default : Char)because byte2is in the middle of'∃'.
Equations
- String.Pos.Raw.get s p = String.Pos.Raw.utf8GetAux s.toList 0 p
Instances For
Equations
- s.get p = String.Pos.Raw.utf8GetAux s.toList 0 p
Instances For
Instances For
Returns the character at position p of a string. If p is not a valid position, returns none.
This function is overridden with an efficient implementation in runtime code. See
String.utf8GetAux? for the reference implementation.
This is a legacy function. The recommended alternative is String.ValidPos.get, combined with
String.pos? or another means of obtaining a String.ValidPos.
Examples:
Equations
- String.Pos.Raw.get? x✝¹ x✝ = String.Pos.Raw.utf8GetAux? x✝¹.toList 0 x✝
Instances For
Equations
- x✝¹.get? x✝ = String.Pos.Raw.utf8GetAux? x✝¹.toList 0 x✝
Instances For
Returns the character at position p of a string. Panics if p is not a valid position.
See String.pos? and String.ValidPos.get for a safer alternative.
This function is overridden with an efficient implementation in runtime code. See
String.utf8GetAux for the reference implementation.
This is a legacy function. The recommended alternative is String.ValidPos.get, combined with
String.pos! or another means of obtaining a String.ValidPos.
Examples
"abc".get! ⟨1⟩ = 'b'
Equations
- String.Pos.Raw.get! s p = String.Pos.Raw.utf8GetAux s.toList 0 p
Instances For
Equations
- s.get! p = String.Pos.Raw.utf8GetAux s.toList 0 p
Instances For
Equations
Instances For
The slice from the beginning of s up to p (exclusive).
Equations
- s.replaceEnd p = s.toSlice.replaceEnd p.toSlice
Instances For
The slice from p (inclusive) up to the end of s.
Equations
- s.replaceStart p = s.toSlice.replaceStart p.toSlice
Instances For
Equations
- s.replaceStartEnd! p₁ p₂ = s.toSlice.replaceStartEnd! p₁.toSlice p₂.toSlice
Instances For
Given a position in s.replaceStart p₀, obtain the corresponding position in s.
Equations
Instances For
Given a position in s that is at least p₀, obtain the corresponding position in
s.replaceStart p₀.
Equations
- p₀.toReplaceStart pos h = { offset := pos.offset.unoffsetBy p₀.offset, isValidForSlice := ⋯ }
Instances For
Given a position in s.replaceEnd p₀, obtain the corresponding position in s.
Equations
- String.ValidPos.ofReplaceEnd pos = { offset := pos.offset, isValid := ⋯ }
Instances For
Given a position in s that is at most p₀, obtain the corresponding position in s.replaceEnd p₀.
Equations
- p₀.toReplaceEnd pos h = { offset := pos.offset, isValidForSlice := ⋯ }
Instances For
Returns the next position in a string after position p. If p is not a valid position or
p = s.endPos, returns the position one byte after p.
A run-time bounds check is performed to determine whether p is at the end of the string. If a
bounds check has already been performed, use String.next' to avoid a repeated check.
This is a legacy function. The recommended alternative is String.ValidPos.next or one of its
variants like String.ValidPos.next?, combined with String.pos or another means of obtaining
a String.ValisPos.
Some examples of edge cases:
"abc".next ⟨3⟩ = ⟨4⟩, since3 = "abc".endPos"L∃∀N".next ⟨2⟩ = ⟨3⟩, since2points into the middle of a multi-byte UTF-8 character
Examples:
Equations
- String.Pos.Raw.next s p = p + String.Pos.Raw.get s p
Instances For
Equations
- s.next p = p + String.Pos.Raw.get s p
Instances For
Instances For
Returns the position in a string before a specified position, p. If p = ⟨0⟩, returns 0. If p
is greater than rawEndPos, returns the position one byte before p. Otherwise, if p occurs in the
middle of a multi-byte character, returns the beginning position of that character.
For example, "L∃∀N".prev ⟨3⟩ is ⟨1⟩, since byte 3 occurs in the middle of the multi-byte
character '∃' that starts at byte 1.
This is a legacy function. The recommended alternative is String.ValidPos.prev or one of its
variants like String.ValidPos.prev?, combined with String.pos or another means of obtaining
a String.ValidPos.
Examples:
"abc".get ("abc".rawEndPos |> "abc".prev) = 'c'"L∃∀N".get ("L∃∀N".rawEndPos |> "L∃∀N".prev |> "L∃∀N".prev |> "L∃∀N".prev) = '∃'
Equations
- String.Pos.Raw.prev x✝¹ x✝ = String.Pos.Raw.utf8PrevAux x✝¹.toList 0 x✝
Instances For
Equations
- x✝¹.prev x✝ = String.Pos.Raw.utf8PrevAux x✝¹.toList 0 x✝
Instances For
Returns the first character in s. If s = "", returns (default : Char).
Examples:
Equations
- s.front = String.Pos.Raw.get s 0
Instances For
Equations
Instances For
Returns the last character in s. If s = "", returns (default : Char).
Examples:
Equations
- s.back = String.Pos.Raw.get s (String.Pos.Raw.prev s s.rawEndPos)
Instances For
Returns true if a specified byte position is greater than or equal to the position which points to
the end of a string. Otherwise, returns false.
Examples:
(0 |> "abc".next |> "abc".next |> "abc".atEnd) = false(0 |> "abc".next |> "abc".next |> "abc".next |> "abc".next |> "abc".atEnd) = true(0 |> "L∃∀N".next |> "L∃∀N".next |> "L∃∀N".next |> "L∃∀N".atEnd) = false(0 |> "L∃∀N".next |> "L∃∀N".next |> "L∃∀N".next |> "L∃∀N".next |> "L∃∀N".atEnd) = true"abc".atEnd ⟨4⟩ = true"L∃∀N".atEnd ⟨7⟩ = false"L∃∀N".atEnd ⟨8⟩ = true
Equations
- String.Pos.Raw.atEnd x✝¹ x✝ = decide (x✝.byteIdx ≥ x✝¹.utf8ByteSize)
Instances For
Returns the character at position p of a string. Returns (default : Char), which is 'A', if
p is not a valid position.
Requires evidence, h, that p is within bounds instead of performing a run-time bounds check as
in String.get.
A typical pattern combines get' with a dependent if-expression to avoid the overhead of an
additional bounds check. For example:
def getInBounds? (s : String) (p : String.Pos) : Option Char :=
if h : s.atEnd p then none else some (s.get' p h)
Even with evidence of ¬ s.atEnd p, p may be invalid if a byte index points into the middle of a
multi-byte UTF-8 character. For example, "L∃∀N".get' ⟨2⟩ (by decide) = (default : Char).
This is a legacy function. The recommended alternative is String.ValidPos.get, combined with
String.pos or another means of obtaining a String.ValidPos.
Examples:
"abc".get' 0 (by decide) = 'a'let lean := "L∃∀N"; lean.get' (0 |> lean.next |> lean.next) (by decide) = '∀'
Equations
- String.Pos.Raw.get' s p h = String.Pos.Raw.utf8GetAux s.toList 0 p
Instances For
Equations
- s.get' p h = String.Pos.Raw.utf8GetAux s.toList 0 p
Instances For
Returns the next position in a string after position p. The result is unspecified if p is not a
valid position.
Requires evidence, h, that p is within bounds. No run-time bounds check is performed, as in
String.next.
A typical pattern combines String.next' with a dependent if-expression to avoid the overhead of
an additional bounds check. For example:
def next? (s : String) (p : String.Pos) : Option Char :=
if h : s.atEnd p then none else s.get (s.next' p h)
This is a legacy function. The recommended alternative is String.ValidPos.next, combined with
String.pos or another means of obtaining a String.ValidPos.
Example:
Equations
- String.Pos.Raw.next' s p h = p + String.Pos.Raw.get s p
Instances For
Equations
- s.next' p h = p + String.Pos.Raw.get s p
Instances For
Returns the position of the first occurrence of a character, c, in a string s. If s does not
contain c, returns s.rawEndPos.
Examples:
Instances For
Returns the position of the last occurrence of a character, c, in a string s. If s does not
contain c, returns none.
Examples:
Equations
- s.revPosOf c = s.revPosOfAux c s.rawEndPos
Instances For
Finds the position of the first character in a string for which the Boolean predicate p returns
true. If there is no such character in the string, then the end position of the string is
returned.
Examples:
Instances For
Equations
- s.revFindAux p pos = if h : pos = 0 then none else have this := ⋯; have pos := String.Pos.Raw.prev s pos; if p (String.Pos.Raw.get s pos) = true then some pos else s.revFindAux p pos
Instances For
Finds the position of the last character in a string for which the Boolean predicate p returns
true. If there is no such character in the string, then none is returned.
Examples:
"coffee tea water".revFind (·.isWhitespace) = some ⟨10⟩"tea".revFind (· == 'X') = none"".revFind (· == 'X') = none
Equations
- s.revFind p = s.revFindAux p s.rawEndPos
Instances For
Returns the first position where the two strings differ.
If one string is a prefix of the other, then the returned position is the end position of the shorter string. If the strings are identical, then their end position is returned.
Examples:
"tea".firstDiffPos "ten" = ⟨2⟩"tea".firstDiffPos "tea" = ⟨3⟩"tea".firstDiffPos "teas" = ⟨3⟩"teas".firstDiffPos "tea" = ⟨3⟩
Equations
- a.firstDiffPos b = String.firstDiffPos.loop a b (a.rawEndPos.min b.rawEndPos) 0
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Creates a new string that consists of the region of the input string delimited by the two positions.
The result is "" if the start position is greater than or equal to the end position or if the
start position is at the end of the string. If either position is invalid (that is, if either points
at the middle of a multi-byte UTF-8 character) then the result is unspecified.
This is a legacy function. The recommended alternative is String.ValidPos.extract, but usually
it is even better to operate on String.Slice instead and call String.Slice.copy (only) if
required.
Examples:
"red green blue".extract ⟨0⟩ ⟨3⟩ = "red""red green blue".extract ⟨3⟩ ⟨0⟩ = """red green blue".extract ⟨0⟩ ⟨100⟩ = "red green blue""red green blue".extract ⟨4⟩ ⟨100⟩ = "green blue""L∃∀N".extract ⟨1⟩ ⟨2⟩ = "∃∀N""L∃∀N".extract ⟨2⟩ ⟨100⟩ = ""
Equations
- String.Pos.Raw.extract x✝² x✝¹ x✝ = if x✝¹.byteIdx ≥ x✝.byteIdx then "" else String.ofList (String.Pos.Raw.extract.go₁ x✝².toList 0 x✝¹ x✝)
Instances For
Equations
- String.Pos.Raw.extract.go₁ [] x✝² x✝¹ x✝ = []
- String.Pos.Raw.extract.go₁ (c :: cs) x✝² x✝¹ x✝ = if x✝² = x✝¹ then String.Pos.Raw.extract.go₂ (c :: cs) x✝² x✝ else String.Pos.Raw.extract.go₁ cs (x✝² + c) x✝¹ x✝
Instances For
Equations
- x✝².extract x✝¹ x✝ = String.Pos.Raw.extract x✝² x✝¹ x✝
Instances For
Splits a string at each character for which p returns true.
The characters that satisfy p are not included in any of the resulting strings. If multiple
characters in a row satisfy p, then the resulting list will contain empty strings.
Examples:
"coffee tea water".split (·.isWhitespace) = ["coffee", "tea", "water"]"coffee tea water".split (·.isWhitespace) = ["coffee", "", "tea", "", "water"]"fun x =>\n x + 1\n".split (· == '\n') = ["fun x =>", " x + 1", ""]
Equations
- s.splitToList p = s.splitAux p 0 0 []
Instances For
Equations
- s.split p = s.splitToList p
Instances For
Auxiliary for splitOn. Preconditions:
sepis not emptyb <= iare indexes intosjis an index intosep, and not at the end
It represents the state where we have currently parsed some split parts into r (in reverse order),
b is the beginning of the string / the end of the previous match of sep, and the first j bytes
of sep match the bytes i-j .. i of s.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Splits a string s on occurrences of the separator string sep. The default separator is " ".
When sep is empty, the result is [s]. When sep occurs in overlapping patterns, the first match
is taken. There will always be exactly n+1 elements in the returned list if there were n
non-overlapping matches of sep in the string. The separators are not included in the returned
substrings.
Examples:
"here is some text ".splitOn = ["here", "is", "some", "text", ""]"here is some text ".splitOn "some" = ["here is ", " text "]"here is some text ".splitOn "" = ["here is some text "]"ababacabac".splitOn "aba" = ["", "bac", "c"]
Instances For
Returns the character index that corresponds to the provided position (i.e. UTF-8 byte index) in a string.
If the position is at the end of the string, then the string's length in characters is returned. If the position is invalid due to pointing at the middle of a UTF-8 byte sequence, then the character index of the next character after the position is returned.
Examples:
"L∃∀N".offsetOfPos ⟨0⟩ = 0"L∃∀N".offsetOfPos ⟨1⟩ = 1"L∃∀N".offsetOfPos ⟨2⟩ = 2"L∃∀N".offsetOfPos ⟨4⟩ = 2"L∃∀N".offsetOfPos ⟨5⟩ = 3"L∃∀N".offsetOfPos ⟨50⟩ = 4
Equations
- s.offsetOfPos pos = s.offsetOfPosAux pos 0 0
Instances For
Equations
- String.Internal.offsetOfPosImpl s pos = s.offsetOfPos pos
Instances For
Equations
- String.foldlAux f s stopPos i a = if h : i < stopPos then have this := ⋯; String.foldlAux f s stopPos (String.Pos.Raw.next s i) (f a (String.Pos.Raw.get s i)) else a
Instances For
Folds a function over a string from the left, accumulating a value starting with init. The
accumulated value is combined with each character in order, using f.
Examples:
"coffee tea water".foldl (fun n c => if c.isWhitespace then n + 1 else n) 0 = 2"coffee tea and water".foldl (fun n c => if c.isWhitespace then n + 1 else n) 0 = 3"coffee tea water".foldl (·.push ·) "" = "coffee tea water"
Equations
- String.foldl f init s = String.foldlAux f s s.rawEndPos 0 init
Instances For
Equations
- String.Internal.foldlImpl f init s = String.foldl f init s
Instances For
Folds a function over a string from the right, accumulating a value starting with init. The
accumulated value is combined with each character in reverse order, using f.
Examples:
"coffee tea water".foldr (fun c n => if c.isWhitespace then n + 1 else n) 0 = 2"coffee tea and water".foldr (fun c n => if c.isWhitespace then n + 1 else n) 0 = 3"coffee tea water".foldr (fun c s => c.push s) "" = "retaw dna aet eeffoc"
Equations
- String.foldr f init s = String.foldrAux f init s s.rawEndPos 0
Instances For
Equations
Instances For
Checks whether there is a character in a string for which the Boolean predicate p returns true.
Short-circuits at the first character for which p returns true.
Examples:
"brown".any (·.isLetter) = true"brown".any (·.isWhitespace) = false"brown and orange".any (·.isLetter) = true"".any (fun _ => false) = false
Instances For
Equations
- String.Internal.containsImpl s c = s.contains c
Instances For
Checks whether the string can be interpreted as the decimal representation of a natural number.
A string can be interpreted as a decimal natural number if it is not empty and all the characters in it are digits.
Use String.toNat? or String.toNat! to convert such a string to a natural number.
Examples:
"".isNat = false"0".isNat = true"5".isNat = true"05".isNat = true"587".isNat = true"-587".isNat = false" 5".isNat = false"2+3".isNat = false"0xff".isNat = false
Instances For
Interprets a string as the decimal representation of a natural number, returning it. Returns none
if the string does not contain a decimal natural number.
A string can be interpreted as a decimal natural number if it is not empty and all the characters in it are digits.
Use String.isNat to check whether String.toNat? would return some. String.toNat! is an
alternative that panics instead of returning none when the string is not a natural number.
Examples:
"".toNat? = none"0".toNat? = some 0"5".toNat? = some 5"587".toNat? = some 587"-587".toNat? = none" 5".toNat? = none"2+3".toNat? = none"0xff".toNat? = none
Equations
Instances For
Checks whether substrings of two strings are equal. Substrings are indicated by their starting
positions and a size in UTF-8 bytes. Returns false if the indicated substring does not exist in
either string.
This is a legacy function. The recommended alternative is to construct slices representing the
strings to be compared and use the BEq instance of String.Slice.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Checks whether the first string (p) is a prefix of the second (s).
String.startsWith is a version that takes the potential prefix after the string.
Examples:
"red".isPrefixOf "red green blue" = true"green".isPrefixOf "red green blue" = false"".isPrefixOf "red green blue" = true
Equations
- p.isPrefixOf s = String.Pos.Raw.substrEq p 0 s 0 p.rawEndPos.byteIdx
Instances For
Equations
Instances For
Returns the position of the beginning of the line that contains the position pos.
Lines are ended by '\n', and the returned position is either 0 : String.Pos or immediately after
a '\n' character.