aboutsummaryrefslogtreecommitdiff
path: root/std/prelude
diff options
context:
space:
mode:
Diffstat (limited to 'std/prelude')
-rw-r--r--std/prelude/io.pk2
-rw-r--r--std/prelude/iterators.pk2
-rw-r--r--std/prelude/lists.pk4
-rw-r--r--std/prelude/numbers.pk4
-rw-r--r--std/prelude/strings.pk18
5 files changed, 15 insertions, 15 deletions
diff --git a/std/prelude/io.pk b/std/prelude/io.pk
index 026d12a..d44f403 100644
--- a/std/prelude/io.pk
+++ b/std/prelude/io.pk
@@ -27,7 +27,7 @@ pub func read(file: File): str? =
pub func lines(file: File): Iter[str] =
...
-pub func chars(file: File): Iter[chr] =
+pub func chars(file: File): Iter[char] =
...
pub func exists(file: File): bool =
diff --git a/std/prelude/iterators.pk b/std/prelude/iterators.pk
index 1403b55..1e60379 100644
--- a/std/prelude/iterators.pk
+++ b/std/prelude/iterators.pk
@@ -159,7 +159,7 @@ pub func unzip[T, U](self: Iter[(T, U)]): (Iter[T], Iter[U])
# equivalent of collect. useful for type conversion
pub func to[T](self: LazyIter[T]): list[T]
-pub func to(self: LazyIter[chr]): str
+pub func to(self: LazyIter[char]): str
pub type BoundIter[T] = class
next(mut Self): T?
diff --git a/std/prelude/lists.pk b/std/prelude/lists.pk
index 1bce693..c4b8739 100644
--- a/std/prelude/lists.pk
+++ b/std/prelude/lists.pk
@@ -7,8 +7,8 @@
@[opaque] # opaque on a struct tells us raw field access breaks invariants.
pub type list[T] = struct
data: ptr T
- capacity: int
- length: int
+ capacity: uint
+ length: uint
## A transparent, common alias for a list of bytes.
pub type bytes = list[byte]
diff --git a/std/prelude/numbers.pk b/std/prelude/numbers.pk
index 801591a..aad747c 100644
--- a/std/prelude/numbers.pk
+++ b/std/prelude/numbers.pk
@@ -65,10 +65,10 @@ pub type dec128
pub type byte = u8
## A primitive char type. 4 bytes wide.
## These represent distinct Unicode characters, and are useful with `str`.
-pub type chr = u32
+pub type char = u32
## Get the underlying length of a char, in bytes. 1-4.
-pub func len(self: chr): uint =
+pub func len(self: char): uint =
...
## The IEEE floating point value of *Not a Number*.
diff --git a/std/prelude/strings.pk b/std/prelude/strings.pk
index a8c72fb..5c71047 100644
--- a/std/prelude/strings.pk
+++ b/std/prelude/strings.pk
@@ -22,7 +22,7 @@ pub func len(self: lent str): uint =
res
## Pushes a character to the end of a mutable string.
-pub func push(self: mut str, val: chr) =
+pub func push(self: mut str, val: char) =
self.data.push(val.byte) # todo: obsolete by from/to conversion??
## Pushes an owned string to the end of a mutable string.
@@ -34,29 +34,29 @@ pub func push(self: mut str, val: str) =
## SAFETY: We return early upon an empty string.
## And decrement by one char for a non-empty string.
@[safe]
-pub func pop(self: mut str): chr? =
+pub func pop(self: mut str): char? =
let char = self.chars.rev.next?
self.data.set_len(self.len - char.len) # this is normally unsafe.
Some(char)
## Returns the character at the provided index, if it exists.
-pub func get(self: str, i: uint): chr? =
+pub func get(self: str, i: uint): char? =
...
## Sets the character at the provided index, if it exists.
## As strings are packed, this may call str.grow and reallocate.
## oh fuck we have to insert + remove anyway
-pub func set(self: mut str, i: uint, val: chr) =
+pub func set(self: mut str, i: uint, val: char) =
...
## Inserts a character at an arbitrary position within a string.
## Panics on failure. (todo: can we do better?)
-pub func insert(self: mut str, i: uint, val: chr) =
+pub func insert(self: mut str, i: uint, val: char) =
...
## Removes and returns a character at an arbitrary position within a string.
## Panics on failure. (todo: can we do better?)
-pub func remove(self: mut str, i: uint): chr =
+pub func remove(self: mut str, i: uint): char? =
...
## Syntactic sugar for string appending.
@@ -70,9 +70,9 @@ pub func &(a: str, b: str): str =
## Conversion from a string to a list of bytes. Zero-cost.
pub func to(self: str): list[byte] = self.data
-## Conversion from a str to a list[chr]. Reallocates.
-pub func to(self: str): list[chr] =
- var res: list[chr]
+## Conversion from a str to a list[char]. Reallocates.
+pub func to(self: str): list[char] =
+ var res: list[char]
for char in self do res.push(char)
res
## Conversion from a char to an array of bytes. Zero-cost.