Welcome to Aria!
This document provides a comprehensive reference for the Aria standard library.
aria.core
Module ReferenceThis document provides a reference for the core types and built-in functionalities of the Aria language.
aria.core.bool
This module provides extensions to the built-in Bool
type.
extension Bool
Extends the built-in Bool
type.
Methods:
hash()
: Returns an integer hash value for the boolean.aria.core.box
This module provides a simple Box
struct, often used as a generic container for values.
Box
A simple struct that can hold arbitrary fields. Often used for returning multiple values or for generic data containers.
Methods:
type func new()
: Creates a new, empty Box
instance.aria.core.file
This module provides functionality for file system interaction.
File
Represents an open file, allowing read and write operations.
Methods:
type func open(path, mode: File.OpenMode)
: Opens a file at the given path
with the specified mode
. path
can be a String
or a Path
object. Returns a File
object. Throws File.IOError
on failure.close()
: Closes the file. This is automatically called when the File
object goes out of scope if used with guard
.read_all()
: Reads the entire content of the file as a String
.read(n: Int)
: Reads up to n
bytes from the file and returns them as a String
.write(s)
: Writes a String
to the file.try_readln()
: Attempts to read a line from the file. Returns Maybe::Some(line_string)
if a line is read, or Maybe::None
if the end of the file is reached.readln()
: Reads a line from the file. Returns an empty string if the end of the file is reached.writeln(s)
: Writes a String
to the file followed by a newline character.get_position()
: Returns the current read/write position within the file as an Int
.set_position(offset: Int)
: Sets the read/write position within the file to offset
.len()
: Returns the size of the file in bytes as an Int
.seek(mode: File.SeekMode)
: Moves the read/write position within the file according to the specified SeekMode
.flush()
: Flushes any buffered writes to the underlying file system.lines()
: Returns an iterator that yields lines from the file.File.OpenMode
A struct used to specify how a file should be opened.
Methods:
type func new()
: Creates a new OpenMode
instance with no flags set.read()
: Sets the read flag. Returns this
for chaining.write()
: Sets the write flag. Returns this
for chaining.append()
: Sets the append flag. Returns this
for chaining.truncate()
: Sets the truncate flag (truncates the file to zero length if it exists). Returns this
for chaining.create()
: Sets the create flag (creates the file if it does not exist). Returns this
for chaining.File.SeekMode
An enumeration specifying how to move the file pointer for seek
operations.
Cases:
Start(Int)
: Seeks to an absolute position from the beginning of the file.Current(Int)
: Seeks relative to the current position.End(Int)
: Seeks relative to the end of the file.aria.core.float
This module provides extensions to the built-in Float
type.
extension Float
Extends the built-in Float
type.
Fields:
pi
(Float): The mathematical constant Pi (π).e
(Float): The mathematical constant e (Euler’s number).π
(Float): Alias for pi
.inf
(Float): Represents positive infinity.nan
(Float): Represents Not-a-Number.epsilon
(Float): The difference between 1.0 and the next representable floating-point number.Methods:
hash()
: Returns an integer hash value for the float.abs()
: Returns the absolute value of the float.sqrt()
: Returns the square root of the float.ln()
: Returns the natural logarithm (base e) of the float. Throws Float.DomainError
if the value is non-positive.exp()
: Returns e (Euler’s number) raised to the power of the float.pow(exponent: Int|Float)
: Returns the float raised to the power of exponent
. Throws Float.DomainError
for invalid operations (e.g., fractional power of a negative number).floor()
: Returns the largest integer less than or equal to the float.ceil()
: Returns the smallest integer greater than or equal to the float.int()
: Returns the integer part of the float (truncates towards zero).type func parse(s: String)
: Attempts to parse a String
into a Float
. Returns Maybe::Some(Float)
on success, Maybe::None
on failure.aria.core.int
This module provides extensions to the built-in Int
type.
extension Int
Extends the built-in Int
type.
Methods:
hash()
: Returns the integer itself as its hash value.abs()
: Returns the absolute value of the integer.float()
: Converts the integer to a Float
.type func parse(s: String)
: Attempts to parse a String
into an Int
. Returns Maybe::Some(Int)
on success, Maybe::None
on failure.aria.core.list
This module provides extensions to the built-in List
type.
extension List
Extends the built-in List
type.
Methods:
len()
: Returns the number of elements in the list.append(x)
: Adds an element x
to the end of the list. Returns the modified list.drop()
: Removes and returns the last element of the list. Throws IndexOutOfBounds
if the list is empty.repeat(n: Int)
: Returns a new list containing this
list repeated n
times.op_mul(rhs: Int)
(Operator *
): Returns a new list containing this
list repeated rhs
times.op_rmul(lhs: Int)
(Operator *
): Handles multiplication when the List
is on the right-hand side of the *
operator.join()
: Returns a string representation of the list elements joined by “, “.contains(x)
: Returns true
if the list contains element x
, false
otherwise.type func from_function(f, n: Int)
: Creates a new list of length n
, where each element is the result of calling function f
with its index.op_equals(rhs: List)
(Operator ==
): Compares this list for equality with rhs
.op_add(rhs: List)
(Operator +
): Returns a new list that is the concatenation of this list and rhs
.quicksort_with_comparator(f)
: Sorts the list in-place using the Quicksort algorithm with a custom comparison function f
. The function f(a, b)
should return true
if a
should come before b
.quicksort()
: Sorts the list in-place using the Quicksort algorithm with the default <
operator for comparison.binary_search(target)
: Performs a binary search for target
in a sorted list. Returns Maybe::Some(index)
if found, Maybe::None
otherwise.aria.core.nothing
This module provides the Nothing
enum, representing the absence of a value.
Nothing
An empty enumeration, used to represent the absence of a value or a type that can never be instantiated.
Cases: (None)
aria.core.path
This module provides a Path
struct for interacting with the file system.
Path
Represents a file system path, providing methods for path manipulation and file system operations.
Methods:
type func new(s: String)
: Creates a new Path
object from a string representation.type func new_with_current_directory()
: Returns a Path
object representing the current working directory.type func new_with_environment_variable(var)
: Returns a Path
object from the value of an environment variable var
.append(rhs: String|Path)
: Appends a component (String
or Path
) to the end of this path. Returns the modified path.op_div(rhs: String|Path)
(Operator /
): Returns a new Path
object by joining this path with rhs
.parent()
: Returns a new Path
object representing the parent directory of this path.read()
: Reads the entire content of the file at this path as a String
. Throws File.IOError
on failure.write(text)
: Writes a String
text
to the file at this path, overwriting existing content. Throws File.IOError
on failure.creation_ms_since_epoch()
: Returns the creation time of the file/directory at this path as milliseconds since the Unix epoch. Returns Maybe::None
if not available.modification_ms_since_epoch()
: Returns the last modification time of the file/directory at this path as milliseconds since the Unix epoch. Returns Maybe::None
if not available.copy_to(other: Path)
: Copies the file at this path to other
. Returns true
on success, false
on failure.is_absolute()
: Returns true
if the path is absolute, false
otherwise.exists()
: Returns true
if the path exists on the file system, false
otherwise.is_directory()
: Returns true
if the path points to a directory, false
otherwise.is_file()
: Returns true
if the path points to a regular file, false
otherwise.is_symlink()
: Returns true
if the path points to a symbolic link, false
otherwise.new_canonical()
: Returns a new Path
object representing the canonical, absolute path (resolving symlinks).size()
: Returns the size of the file at this path in bytes as an Int
. Returns Maybe::None
if not a file or path does not exist.get_filename()
: Returns the final component of the path (the file or directory name) as a String
. Returns Maybe::None
if the path has no filename component.get_extension()
: Returns the extension of the file at this path as a String
. Returns Maybe::None
if the path has no extension.entries()
: Returns a List
of Path
objects representing the entries (files and subdirectories) within the directory pointed to by this path.mkdir()
: Creates a new directory at this path. Returns true
on success, false
on failure.rmdir()
: Removes an empty directory at this path. Returns true
on success, false
on failure.erase()
: Removes the file at this path. Returns true
on success, false
on failure.aria.core.string
This module provides extensions to the built-in String
type.
extension String
Extends the built-in String
type.
Methods:
repeat(n: Int)
: Returns a new string containing this
string repeated n
times.op_mul(rhs: Int)
(Operator *
): Returns a new string containing this
string repeated rhs
times.op_rmul(lhs: Int)
(Operator *
): Handles multiplication when the String
is on the right-hand side of the *
operator.trim()
: Returns a new string with leading and trailing whitespace removed.format(...)
: Formats the string using positional arguments. Placeholders like {0}
are replaced by corresponding arguments. Supports `` for literal braces.substring(from: Int, to: Int)
: Returns a new string that is a substring of this
string, starting at from
(inclusive) and ending at to
(inclusive).hash()
: Returns an integer hash value for the string.len()
: Returns the length of the string in bytes.has_prefix(prefix: String)
: Returns true
if the string starts with prefix
, false
otherwise.has_suffix(suffix: String)
: Returns true
if the string ends with suffix
, false
otherwise.replace(current: String, wanted: String)
: Returns a new string with all occurrences of current
replaced by wanted
.split(marker: String)
: Splits the string by marker
and returns a List
of substrings.chars()
: Returns a List
of single-character strings representing the characters in the string.bytes()
: Returns a List
of integers representing the UTF-8 byte values of the string.type func new_with_bytes(bytes: List)
: Creates a new String
from a List
of byte integers. Throws String.EncodingError
if the bytes are not valid UTF-8.encoding()
: Returns the numeric UTF-8 encoding of the first character of the string as an Int
. (Intended for single-character strings).uppercase()
: Returns a new string with all characters converted to uppercase.lowercase()
: Returns a new string with all characters converted to lowercase.contains(substring: String)
: Returns true
if the string contains the substring
, false
otherwise.Maybe
(Built-in Enum)Maybe
is a built-in enumeration that represents a value that may or may not be present. It is similar to Optional
in other languages.
Maybe
An enumeration that can either contain a value (Some
) or indicate the absence of a value (None
).
Cases:
Some(Any)
: Contains a value of any type.None
: Represents the absence of a value.Methods:
is_Some()
: Returns true
if the Maybe
contains a value (Some
), false
otherwise.is_None()
: Returns true
if the Maybe
does not contain a value (None
), false
otherwise.unwrap_Some()
: Returns the value contained within Some
. Throws EnumWithoutPayload
if called on None
.unwrap_or(default_value)
: Returns the value contained within Some
, or default_value
if it is None
.apply(f)
: If Maybe
is Some(value)
, applies the function f
to value
and returns the result. If Maybe
is None
, returns None
.Unit
(Built-in Enum)Unit
is a built-in enumeration that represents the absence of any meaningful value. It is similar to void
in C-like languages or ()
in Rust.
Unit
An enumeration with a single case, used to indicate that a function returns no meaningful value, or as a placeholder where a type is required but no data is conveyed.
Cases: unit
: Represents the unit value
aria.date
Module ReferenceThis document provides a reference for the aria.date
module, which contains utilities for handling dates and times.
aria.date.instant
This module provides a struct for representing a specific moment in time, similar to a timestamp, but with calendar and time components.
Instant
An object that represents a single point in time, broken down into calendar and clock elements. It can be created from a Unix timestamp and can account for timezone offsets.
Fields:
year
(Int): The year (e.g., 2025).month
(Int): The month of the year (1-12).day
(Int): The day of the month (1-31).hour
(Int): The hour of the day (0-23).minute
(Int): The minute of the hour (0-59).second
(Int): The second of the minute (0-59).millisecond
(Int): The millisecond of the second (0-999).unix_ts
(Int): The original Unix timestamp in milliseconds that this Instant
was created from.offset_ms
(Int): The timezone offset from UTC in milliseconds.Methods:
type func from_unix_timestamp(timestamp_ms)
: Creates a new Instant
object from a provided Unix timestamp (in milliseconds), assuming UTC.type func from_localtime_unix_timestamp(timestamp_ms, offset_minutes)
: Creates a new Instant
object from a provided Unix timestamp (in milliseconds), adjusted for a given timezone offset (in minutes).instance func prettyprint()
: Returns a formatted string representation of the Instant
.aria.iterator
Module ReferenceThis document provides a reference for the aria.iterator
module, which contains core interfaces and utilities for working with iterators and iterable collections.
aria.iterator.mixin
This module defines the fundamental Iterator
and Iterable
mixins, which enable collections to be traversed and transformed.
Iterator
A mixin that defines the contract for an object that can be iterated over. It provides common functional methods for transforming the iteration stream.
Requirements:
next()
that returns a Box
object with two fields: .done
(a Bool
indicating if the iteration is complete) and .value
(the current item, present only if .done
is false
).Methods Offered:
map(f)
: Returns a new iterator that applies the function f
to each item yielded by this iterator.where(f)
: Returns a new iterator that yields only the items for which the predicate function f
returns true
.reduce(f, initial)
: Applies a function f
against an accumulator and each item in the iterator (from left to right) to reduce it to a single value. initial
is the starting value of the accumulator.to_list()
: Consumes the iterator and returns a List
containing all its items.all(f)
: Returns true
if the predicate function f
returns true
for all items in the iterator, false
otherwise. This method short-circuits, i.e. it stops consuming the iterator as soon as the outcome is determined.any(f)
: Returns true
if the predicate function f
returns true
for at least one item in the iterator, false
otherwise. This method short-circuits, i.e. it stops consuming the iterator as soon as the outcome is determined.find(f)
: Returns Maybe::Some(value)
for the first item for which the predicate function f
returns true
, or Maybe::None
if no such item is found.position(f)
: Returns Maybe::Some(index)
for the first item for which the predicate function f
returns true
, or Maybe::None
if no such item is found.sum()
: Consumes the iterator and returns the sum of all its items. Assumes items support the +
operator.product()
: Consumes the iterator and returns the product of all its items. Assumes items support the *
operator.max()
: Returns Maybe::Some(value)
with the maximum value in the iterator, or Maybe::None
if the iterator is empty. Assumes items support the >
operator.min()
: Returns Maybe::Some(value)
with the minimum value in the iterator, or Maybe::None
if the iterator is empty. Assumes items support the <
operator.count()
: Consumes the iterator and returns the total number of items.first()
: Returns Maybe::Some(value)
with the first item of the iterator, or Maybe::None
if the iterator is empty.last()
: Consumes the iterator and returns Maybe::Some(value)
with the last item, or Maybe::None
if the iterator was empty.nth(n: Int)
: Consumes the iterator up to the nth item and returns Maybe::Some(value)
. Returns Maybe::None
if n
is negative or the iterator has fewer than n+1
items.iterator()
: Returns the iterator itself, allowing an Iterator
to be used where an iterable value is expected.Iterable
A mixin that defines the contract for an object that can produce an Iterator
. It provides convenience methods that delegate to the iterator produced by the iterator()
method.
Requirements:
iterator()
that returns an Iterator
object.Methods Offered:
map(f)
: Returns a new iterator that applies the function f
to each item yielded by this iterable’s iterator.where(f)
: Returns a new iterator that yields only the items for which the predicate function f
returns true
.reduce(f, initial)
: Applies a function f
against an accumulator and each item in the iterable (from left to right) to reduce it to a single value. initial
is the starting value of the accumulator.to_list()
: Returns a List
containing all items from this iterable’s iterator.all(f)
: Returns true
if the predicate function f
returns true
for all items, false
otherwise.any(f)
: Returns true
if the predicate function f
returns true
for at least one item, false
otherwise.find(f)
: Returns Maybe::Some(value)
for the first item for which the predicate function f
returns true
, or Maybe::None
if no such item is found.position(f)
: Returns Maybe::Some(index)
for the first item for which the predicate function f
returns true
, or Maybe::None
if no such item is found.sum()
: Returns the sum of all items. Assumes items support the +
operator.product()
: Returns the product of all items. Assumes items support the *
operator.max()
: Returns Maybe::Some(value)
with the maximum value, or Maybe::None
if the iterable is empty. Assumes items support the >
operator.min()
: Returns Maybe::Some(value)
with the minimum value, or Maybe::None
if the iterable is empty. Assumes items support the <
operator.count()
: Returns the total number of items.first()
: Returns Maybe::Some(value)
with the first item, or Maybe::None
if the iterable is empty.last()
: Returns Maybe::Some(value)
with the last item, or Maybe::None
if the iterable is empty.nth(n: Int)
: Returns Maybe::Some(value)
for the nth item. Returns Maybe::None
if n
is out of bounds.aria.iterator.enumerate
This module provides an extension to Iterable
that allows iterating with an index.
extension Iterable
Extends any Iterable
object with an enumerate
method.
Methods:
enumerate()
: Returns a new iterator that yields Box
objects with .index
(the 0-based index) and .value
(the item) for each item in the iterable.aria.iterator.zip
This module provides an extension to Iterable
that allows combining two iterables into one.
extension Iterable
Extends any Iterable
object with a zip
method.
Methods:
zip(other)
: Returns a new iterator that yields Box
objects with .first
(from this iterable) and .second
(from the other
iterable) for each corresponding pair of items. The iteration stops when either iterable is exhausted.aria.json
Module ReferenceThis document provides a reference for the aria.json
module, which contains functionality for parsing and generating JSON data.
aria.json.value
This module defines the core JsonValue
enum, which represents any JSON data type.
JsonNull
A placeholder struct representing the JSON null
value.JsonValue
An enumeration that can hold any valid JSON data type.
Cases:
Object(Map)
: Represents a JSON object, mapping string keys to JsonValue
s.Array(List)
: Represents a JSON array, a list of JsonValue
s.String(String)
: Represents a JSON string.Number(Float)
: Represents a JSON number.Boolean(Bool)
: Represents a JSON boolean (true
or false
).Null(JsonNull)
: Represents a JSON null
value.Methods:
flatten()
: Recursively converts a JsonValue
(and its nested Object
s and Array
s) into native Aria Map
s, List
s, String
s, Float
s, Bool
s, and JsonNull
s. This is useful for working with parsed JSON data using standard Aria types.type func new_from_value(x)
: Converts a native Aria value (String
, Int
, Float
, Bool
, List
, Map
, JsonNull
) into its corresponding JsonValue
enum case. For List
s and Map
s, the conversion is recursive. If x
is a custom type that has a to_json_value()
method, that method will be called to perform the conversion. Throws JsonConvertError
if the type cannot be converted.aria.json.parser
This module provides functionality for parsing JSON strings into JsonValue
objects.
extension JsonValue
Extends the JsonValue
enum with parsing capabilities.
Methods:
type func parse(s)
: Parses a JSON formatted String
s
and returns a JsonValue
representation of the data. Throws JsonParseError
if the string is not valid JSON.aria.json.writer
This module provides functionality for serializing JsonValue
objects into JSON strings.
extension JsonValue
Extends the JsonValue
enum with serialization capabilities.
Methods:
to_json_string()
: Converts the JsonValue
object into its JSON string representation. This method handles the recursive serialization of nested objects and arrays.aria.network
Module ReferenceThis document provides a reference for the aria.network
module, which contains functionality for making HTTP requests.
aria.network.request
This module provides the Request
struct for building and sending HTTP requests.
Request
A builder-style struct used to configure and send HTTP requests.
Fields:
url
(String): The URL for the request.headers
(Map): A map of header names to header values for the request.timeout
(Float): The timeout for the request in seconds.Methods:
type func new(url: String)
: Creates a new Request
instance for the given url
, with an empty headers map and a default timeout.get()
: Sends an HTTP GET request using the configured Request
object. Returns a Request.Response
object.post(data: String)
: Sends an HTTP POST request with the given data
string as the body. Returns a Request.Response
object.post_as_json(data)
: Sends an HTTP POST request with the given data
(which can be any native Aria type convertible to JSON) as a JSON-formatted body. Automatically sets the Content-Type
header to application/json
. Returns a Request.Response
object.Request.Response
An inner struct within Request
that represents the response received from an HTTP request.
Fields:
status_code
(Int): The HTTP status code of the response (e.g., 200, 404).headers
(Map): A map of header names to header values from the response.content
(String): The body of the response as a string.aria.numerics
Module ReferenceThis document provides a reference for the aria.numerics
module, which contains advanced numerical types and functions.
aria.numerics.complex
This module provides a Complex
number type.
Complex
Represents a complex number with real and imaginary parts.
Fields:
real
(Float): The real component of the complex number.imag
(Float): The imaginary component of the complex number.Methods:
type func new(r, i)
: Creates a new Complex
number with real part r
and imaginary part i
.type func zero()
: Returns a new Complex
number representing zero (0 + 0i).conj()
: Returns the complex conjugate of the number.reciprocal()
: Returns the reciprocal (1/z) of the complex number.op_add(rhs)
(Operator +
): Adds this complex number to rhs
. rhs
can be an Int
, Float
, or Complex
.op_radd(lhs)
(Operator +
): Handles addition when the Complex
number is on the right-hand side of the +
operator.op_mul(rhs)
(Operator *
): Multiplies this complex number by rhs
. rhs
can be an Int
, Float
, or Complex
.op_rmul(lhs)
(Operator *
): Handles multiplication when the Complex
number is on the right-hand side of the *
operator.op_div(rhs)
(Operator /
): Divides this complex number by rhs
. rhs
can be an Int
, Float
, or Complex
.op_rdiv(lhs)
(Operator /
): Handles division when the Complex
number is on the right-hand side of the /
operator.op_sub(rhs)
(Operator -
): Subtracts rhs
from this complex number. rhs
can be an Int
, Float
, or Complex
.op_rsub(lhs)
(Operator -
): Handles subtraction when the Complex
number is on the right-hand side of the -
operator.op_equals(rhs)
(Operator ==
): Compares this complex number for equality with rhs
. rhs
can be an Int
, Float
, or Complex
.aria.numerics.decimal
This module provides a Decimal
number type for arbitrary-precision decimal arithmetic.
Decimal
Represents a decimal number with a specific value and scale, designed for precise financial or scientific calculations where floating-point inaccuracies are unacceptable.
Fields:
value
(Int): The unscaled integer value of the decimal number.scale
(Int): The number of digits after the decimal point.Methods:
type func new(v)
: Creates a new Decimal
from an Int
or Float
value.type func new_with_parts(v: Int, s: Int)
: Creates a new Decimal
from an integer value
and a scale
.type func parse(s: String)
: Creates a new Decimal
from a String
. Returns a Maybe
value.op_add(other)
(Operator +
): Adds this decimal number to other
. other
can be an Int
, Float
, or Decimal
.op_radd(lhs)
(Operator +
): Handles addition when the Decimal
number is on the right-hand side of the +
operator.op_sub(other)
(Operator -
): Subtracts other
from this decimal number. other
can be an Int
, Float
, or Decimal
.op_rsub(lhs)
(Operator -
): Handles subtraction when the Decimal
number is on the right-hand side of the -
operator.op_mul(other)
(Operator *
): Multiplies this decimal number by other
. other
can be an Int
, Float
, or Decimal
.op_rmul(lhs)
(Operator *
): Handles multiplication when the Decimal
number is on the right-hand side of the *
operator.op_div(other)
(Operator /
): Divides this decimal number by other
. other
can be an Int
, Float
, or Decimal
.op_rdiv(lhs)
(Operator /
): Handles division when the Decimal
number is on the right-hand side of the /
operator.comp(other)
: Compares this decimal number to other
and returns a CompareResult
(lt
, eq
, gt
). other
can be an Int
, Float
, or Decimal
.TotalOrdering
) op_equals(rhs)
(Operator ==
)TotalOrdering
) op_lt(rhs)
(Operator <
)TotalOrdering
) op_gt(rhs)
(Operator >
)TotalOrdering
) op_lteq(rhs)
(Operator <=
)TotalOrdering
) op_gteq(rhs)
(Operator >=
)aria.numerics.matrix
This module provides a Matrix
type for linear algebra operations.
Matrix
Represents a mathematical matrix, supporting common matrix operations.
Fields:
rows
(Int): The number of rows in the matrix.cols
(Int): The number of columns in the matrix.data
(Map): Internal storage for matrix elements, mapping MatrixIndex
to values.Methods:
type func new(rows: Int, cols: Int)
: Creates a new Matrix
with the specified number of rows and columns, initialized with 0.0f
.get(row: Int, col: Int)
: Retrieves the value at the specified row
and col
. Throws Matrix.DimensionMismatch
if indices are out of bounds.set(row: Int, col: Int, value)
: Sets the value
at the specified row
and col
. Throws Matrix.DimensionMismatch
if indices are out of bounds.op_add(other: Matrix)
(Operator +
): Adds this matrix to other
. Throws Matrix.DimensionMismatch
if dimensions do not match.op_sub(other: Matrix)
(Operator -
): Subtracts other
from this matrix. Throws Matrix.DimensionMismatch
if dimensions do not match.op_mul(other: Matrix)
(Operator *
): Multiplies this matrix by other
. Throws Matrix.DimensionMismatch
if dimensions do not match for multiplication.transpose()
: Returns a new Matrix
that is the transpose of this matrix.determinant()
: Calculates the determinant of the matrix. Throws Matrix.DimensionMismatch
if the matrix is not square.op_equals(other: Matrix)
(Operator ==
): Compares this matrix for equality with other
.aria.numerics.trig
This module provides trigonometric functions as extensions to the Float
type.
extension Float
Extends the built-in Float
type with trigonometric and inverse trigonometric functions.
Methods:
sin()
: Returns the sine of the float value (in radians).cos()
: Returns the cosine of the float value (in radians).tan()
: Returns the tangent of the float value (in radians).arcsin()
: Returns the arcsine (inverse sine) of the float value (in radians). Throws Float.DomainError
if the input is outside [-1.0, 1.0]
.arccos()
: Returns the arccosine (inverse cosine) of the float value (in radians). Throws Float.DomainError
if the input is outside [-1.0, 1.0]
.arctan()
: Returns the arctangent (inverse tangent) of the float value (in radians).aria.ordering
Module ReferenceThis document provides a reference for the aria.ordering
module, which contains utilities and mixins for comparing and ordering values.
aria.ordering.compare
This module defines the result of a comparison operation and a mixin for implementing total ordering.
CompareResult
An enumeration representing the outcome of a comparison between two values.
Cases:
lt
: The first value is less than the second.eq
: The first value is equal to the second.gt
: The first value is greater than the second.TotalOrdering
A mixin that provides standard comparison operators (==
, <
, >
, <=
, >=
) for a struct, given that the struct implements a core comparison method.
Requirements:
comp(other)
that returns a CompareResult
enum value (lt
, eq
, or gt
) indicating the relationship between this
object and other
.Methods Offered:
op_equals(rhs)
(Operator ==
): Returns true
if this
is equal to rhs
.op_lt(rhs)
(Operator <
): Returns true
if this
is less than rhs
.op_gt(rhs)
(Operator >
): Returns true
if this
is greater than rhs
.op_lteq(rhs)
(Operator <=
): Returns true
if this
is less than or equal to rhs
.op_gteq(rhs)
(Operator >=
): Returns true
if this
is greater than or equal to rhs
.aria.ordering.utils
This module provides utility functions for finding minimum, maximum, and min-max values in a list.
min(l: List)
: Returns the minimum value in the provided list l
using the default <
operator. Throws an error if the list is empty.min_with_comparator(l: List, cmp)
: Returns the minimum value in the provided list l
using a custom comparator function cmp
. The cmp
function should take two arguments and return a CompareResult
.max(l: List)
: Returns the maximum value in the provided list l
using the default >
operator. Throws an error if the list is empty.max_with_comparator(l: List, cmp)
: Returns the maximum value in the provided list l
using a custom comparator function cmp
. The cmp
function should take two arguments and return a CompareResult
.min_max(l: List)
: Returns a Box
object with .min
and .max
fields, containing the minimum and maximum values in the provided list l
using default comparison operators. Throws an error if the list is empty.min_max_with_comparator(l: List, cmp)
: Returns a Box
object with .min
and .max
fields, containing the minimum and maximum values in the provided list l
using a custom comparator function cmp
. The cmp
function should take two arguments and return a CompareResult
.aria.range
Module ReferenceThis document provides a reference for the aria.range
module, which contains utilities for creating and manipulating numeric ranges.
aria.range.int_extension
This module extends the built-in Int
type with convenient methods for creating ranges.
extension Int
Extends the built-in Int
type with methods to easily create Range
objects.
Methods:
to(n: Int)
: Creates a range from this
integer up to (but not including) n
. For example, 1.to(5)
creates a range [1, 2, 3, 4]
.through(n: Int)
: Creates a range from this
integer up to and including n
. For example, 1.through(5)
creates a range [1, 2, 3, 4, 5]
.aria.range.range
This module provides the core Range
types and their associated functionality.
RangeImpl
Represents a concrete numeric range (e.g., [from, to)
). This is the object returned by Range.from(...).to(...)
or Range.from(...).through(...)
.
Methods:
step(n)
: Returns an iterator that iterates through the range with the specified step n
. Throws InvalidRangeError
if n
is zero.iterator()
: Returns an iterator that iterates through the range with a step of 1
.descending()
: Returns an iterator that iterates through the range in reverse order with a step of -1
.contains(x)
: Returns true
if x
is within the range, false
otherwise.length()
: Returns the number of elements in the range.union(other)
: Returns a new RangeImpl
representing the union of this range and other
.intersection(other)
: Returns a new RangeImpl
representing the intersection of this range and other
.prettyprint()
: Returns a string representation of the range.RangeFrom
An intermediate object used in the fluent API for creating ranges (e.g., Range.from(X)
returns a RangeFrom
object).
Methods:
type func new(n)
: Creates a new RangeFrom
object starting from n
.to(n)
: Completes the range definition, creating a RangeImpl
from this.from
up to (but not including) n
. Throws InvalidRangeError
if this.from
is greater than n
.through(n)
: Completes the range definition, creating a RangeImpl
from this.from
up to and including n
. Throws InvalidRangeError
if this.from
is greater than n
.Range
The primary entry point for creating ranges using a fluent API.
Methods:
type func from(n)
: Starts a new range definition from n
, returning a RangeFrom
object.aria.rng
Module ReferenceThis document provides a reference for the aria.rng
module, which contains utilities for random number generation.
aria.rng.mixin
This module provides a mixin for adding common functionality to Random Number Generator (RNG) structs.
RngRange
A mixin that provides methods for generating random numbers within a specific range or selecting a random element from a list.
Requirements:
next()
that returns a random integer.Methods Offered:
in_range(low, high)
: Returns a random integer within the inclusive range [low, high]
.one_of(x: List)
: Returns a random element from the provided list x
.aria.rng.msws
This module provides an implementation of the Middle-Square Weyl Sequence RNG.
MiddleSquareRng
An object that generates pseudo-random numbers using the Middle-Square Weyl Sequence algorithm.
Methods:
type func new()
: Creates a new MiddleSquareRng
instance, seeded with the current system time.type func new_with_params(x, s)
: Creates a new MiddleSquareRng
instance with a specific starting value x
and a Weyl sequence value s
.next()
: Returns the next pseudo-random integer in the sequence.RngRange
) in_range(low, high)
RngRange
) one_of(x: List)
aria.rng.xorshift
This module provides an implementation of the Xorshift RNG.
XorshiftRng
An object that generates pseudo-random numbers using the Xorshift algorithm.
Methods:
type func new()
: Creates a new XorshiftRng
instance, seeded with the current system time.type func new_with_seed(seed)
: Creates a new XorshiftRng
instance with a specific seed value.next()
: Returns the next pseudo-random integer in the sequence.RngRange
) in_range(low, high)
RngRange
) one_of(x: List)
aria.string
Module ReferenceThis document provides a reference for the aria.string
module, which contains utilities and extensions for working with strings.
aria.string.classes
This module provides methods to check if a single-character string belongs to a certain character class (e.g., digit, letter).
extension String
This extends the built-in String
type with the following instance methods. These methods are intended to be called on strings containing only a single character.
Methods:
is_digit()
: Returns true
if the character is a numeric digit (‘0’-‘9’), false
otherwise.is_uppercase_letter()
: Returns true
if the character is an uppercase ASCII letter (‘A’-‘Z’), false
otherwise.is_lowercase_letter()
: Returns true
if the character is a lowercase ASCII letter (‘a’-‘z’), false
otherwise.is_letter()
: Returns true
if the character is an uppercase or lowercase ASCII letter, false
otherwise.is_alphanumeric()
: Returns true
if the character is an ASCII letter or a numeric digit, false
otherwise.is_whitespace()
: Returns true
if the character is a space, newline, carriage return, or tab, false
otherwise.aria.string.regex
This module provides regular expression functionality.
Regex
Represents a compiled regular expression.
Fields:
pattern
(String): The regular expression pattern string.Methods:
type func new(pattern: String)
: Compiles a new Regex
from the given pattern
string. Throws Regex.Error
if the pattern is invalid.any_match(text: String)
: Returns true
if the regex matches any part of the text
, false
otherwise.matches(text: String)
: Searches for every match of the regex in text
. Returns a List
of Regex.Match
objects, potentially empty if no matches are found.replace(text: String, with: String)
: Searches for every match of the regex in text
and replaces each occurrence with with
. Returns a String
with all the substitutions performed.Regex.Match
Represents a single match found by a regular expression.
Fields:
start
(Int): The starting byte index of the match in the input string.len
(Int): The length of the match in bytes.value
(String): The matched string itself.aria.structures
Module ReferenceThis document provides a reference for the aria.structures
module, which contains common data structures.
aria.structures.map
This module provides a hash map implementation.
Map
A collection of key-value pairs, implemented as a hash map. Keys must provide a hash()
method.
Methods:
type func new()
: Creates a new, empty Map
with a default capacity.type func new_with_capacity(n: Int)
: Creates a new, empty Map
with a specified initial capacity.set(k, v)
: Sets the value v
for the key k
. If the key already exists, its value is overwritten.get(k)
: Retrieves the value for key k
. Returns Maybe::Some(value)
if the key exists, otherwise Maybe::None
.remove(k)
: Removes a key and its associated value from the map.contains(k)
: Returns true
if the map contains the given key, false
otherwise.len()
: Returns the number of key-value pairs in the map.keys()
: Returns a List
of all keys in the map.read_index(k)
(Operator []
): Retrieves the value for key k
. Throws an exception if the key does not exist.write_index(k, v)
(Operator []=
): Sets the value v
for the key k
.iterator()
: Returns an iterator that yields key-value pairs (as Box
objects with .key
and .value
fields) for use in for
loops.prettyprint()
: Returns a string representation of the map.aria.structures.queue
This module provides a priority queue.
PriorityQueue
A queue that orders its elements based on a priority. By default, it acts as a min-heap.
Methods:
type func new()
: Creates a new, empty PriorityQueue
that uses the default <
operator for comparison (min-heap).type func new_with_comparator(cmp)
: Creates a new, empty PriorityQueue
with a custom comparator function. The function cmp(a, b)
should return true
if a
has a higher priority than b
.push(item)
: Adds an item to the queue.pop()
: Removes and returns the item with the highest priority from the queue. Throws an exception if the queue is empty.peek()
: Returns the highest priority item without removing it. Returns Maybe::Some(item)
or Maybe::None
if the queue is empty.len()
: Returns the number of items in the queue.aria.structures.set
This module provides a collection of unique items.
Set
A collection that stores unique values, implemented using a Map
internally. Items must provide a hash()
method.
Methods:
type func new()
: Creates a new, empty Set
.type func new_from_items(...)
: Creates a new Set
populated with the provided arguments.set(x)
: Adds an item to the set. If the item already exists, this has no effect.contains(x)
: Returns true
if the set contains the given item, false
otherwise.remove(x)
: Removes an item from the set.len()
: Returns the number of items in the set.union(other)
: Returns a new Set
containing all items present in either this set or the other
set.intersection(other)
: Returns a new Set
containing only the items present in both this set and the other
set.difference(other)
: Returns a new Set
containing items present in this set but not in the other
set.iterator()
: Returns an iterator that yields the items in the set for use in for
loops.aria.structures.stack
This module provides a last-in, first-out (LIFO) stack.
Stack
A LIFO data structure.
Methods:
type func new()
: Creates a new, empty Stack
.push(x)
: Adds an item to the top of the stack.pop()
: Removes and returns the item from the top of the stack. Throws an exception if the stack is empty.try_pop()
: Removes and returns the top item as Maybe::Some(item)
, or returns Maybe::None
if the stack is empty.peek()
: Returns the top item without removing it, as Maybe::Some(item)
, or Maybe::None
if the stack is empty.peek_at(offset)
: Returns the item at a given offset
from the top of the stack without removing it (e.g., peek_at(1)
looks at the second item from the top). Returns a Maybe
value.len()
: Returns the number of items in the stack.is_empty()
: Returns true
if the stack contains no items, false
otherwise.aria.test
Module ReferenceThis document provides a reference for the aria.test
module, which contains utilities for writing and running tests.
aria.test.test
This module provides the core components for defining test cases and organizing them into test suites.
TestResult
An enumeration representing the outcome of a test case execution.
Cases:
Pass
: The test case executed successfully without any failures.Fail(String)
: The test case failed, with the String
payload providing a description of the failure.TestCase
A mixin that provides common testing utilities and a run
method for executing a test.
Requirements:
test()
which contains the actual test logic. This method is expected not to throw any errors for a passing test.setup()
and teardown()
instance methods. If present, setup()
is called before test()
, and teardown()
is called after test()
(regardless of test()
’s outcome).Methods Offered:
type func new()
: Creates a new instance of the test case.run()
: Executes the test case. It calls setup()
(if present), then test()
, and finally teardown()
(if present). It catches exceptions thrown by test()
and returns a TestResult::Fail
if the test fails or throws an exception. Returns TestResult::Pass
on success.assert_equal(expected, actual)
: Asserts that expected
is equal to actual
. Throws ComparisonMismatch
if they are not equal.assert_not_equal(expected, actual)
: Asserts that expected
is not equal to actual
. Throws ComparisonMismatch
if they are equal.assert_throws(f)
: Asserts that calling the function f
throws an exception. If f
does not throw, it throws OperationFailure
.TestSuite
A container for organizing and running multiple TestCase
instances.
Fields:
name
(String): The name of the test suite.tests
(List): A list of TestCase
instances to be run.Methods:
type func new(name)
: Creates a new TestSuite
with the given name
.add_test(test)
: Adds a TestCase
instance to the suite. Returns the TestSuite
instance for chaining.run()
: Executes all test cases added to the suite. Prints the result of each test and a summary of passed/failed tests. Returns the number of failed tests.