Standard Docs

Documentation For Every Feature

About Modules

Maid includes basic module functionality using the fetch keyword.

  • To use the fetch keyword, provide the module name (file name)
fetch std_math;
serve(math_pi); // object defined in the math module

Upon importing, objects are only appended to the current scope.

func i() {
    fetch std_math;
}
i();
serve(math_pi); // we cant access this here

std_hashmap

std_hashmap is an implementation of the hashmap data type, also known as a dictionary or table.

fetch(std_hashmap);
obj my_hashmap = hashmap();
obj my_hashmap = hashmap_set(my_hashmap, "user", "darling");
obj my_hashmap = hashmap_set(my_hashmap, "age", 23);
obj my_hashmap = hashmap_set(my_hashmap, "birthday", "1/1/25");
obj birthday = hashmap_get(my_hashmap, "birthday");

serve(birthday); // output: 1/1/25

hashmap

Constructs a new hashmap and returns it.

obj example = hashmap();

serve(example);

hashmap_set

Sets the hashmap's key-value pair and returns a new version of it.

obj example = hashmap();

obj example = hashmap_set(example, "key", "value");

serve(example);

hashmap_get

Returns the value for a given key in the hashmap.

obj example = hashmap();

obj example = hashmap_set(example, "key", "value");

serve(hashmap_get(example, "key")); // output: value

hashmap_remove

Removes a key from the hashmap and returns a new hashmap without it.

obj example = hashmap();

obj example = hashmap_set(example, "key", "value");

obj removed = hashmap_remove(example, "key");

serve(removed); // output: {}

hashmap_keys

Returns a list of all keys in the hashmap.

obj example = hashmap();

obj example = hashmap_set(example, "key1", "value");
obj example = hashmap_set(example, "key2", "value");

obj keys = hashmap_keys(example);

serve(keys); // output: [key1, key2]

hashmap_values

Returns a list of all values in the hashmap.

obj example = hashmap();

obj example = hashmap_set(example, "key1", "value1");
obj example = hashmap_set(example, "key2", "value2");

obj values = hashmap_values(example);

serve(values); // output: [value1, value2]

serve_hashmap

Pretty print a hashmap (formerly serve_hashmap).

obj example = hashmap();

obj example = hashmap_set(example, "key1", "value1");

serve_hashmap(example);

// output:
// {
//     key1: value1
// }

std_os

std_os provides operating system related features.

fetch std_os;

serve(os_type());

os_type

Returns the name of the operating system.

  • "windows" on Windows
  • "macos" on Mac
  • "unknown" if unrecognized
obj example = os_type();

serve(example); // 'windows', 'macos', or 'unknown'

os_path

Returns the system's PATH environment variable.

obj example = os_path();

serve(example);

os_user_dir

Returns the full user directory path.

  • On Windows: C:/Users/YourName
  • On macOS: /Users/YourName
obj example = os_user_dir();

serve(example);

os_env

Returns the value of a specific OS environment variable.

obj example = os_env("PATH");

serve(example);

std_format

std_format provides built-in support for string formatting.

fetch std_format;

obj my_string = format("Hello, {}!", "George");

serve(my_string); // output: Hello, George!

// You can also use multiple placeholders
obj my_string2 = format("Hello, {}, {}, {}!", "A", "B", "C");

serve(my_string2); # output: Hello, A, B, C!

format

Formats a string with a given value or values.

The value is automatically converted to a string using tostring, so any type can be passed.

obj example = format("Testing {}", 123);

serve(example); // output: Testing 123