pub const LIS_PRELUDE_SOURCE: &str = "// Lisette prelude type definitions\n//\n// This file declares the types available in every Lisette program \n// without an explicit import. The compiler embeds this file at build\n// time for type checking.\n\n// -----------------------\n// Primitive types\n// -----------------------\n\n/// Signed integer (platform-dependent size).\ntype int\n\n/// 8-bit signed integer.\ntype int8\n\n/// 16-bit signed integer.\ntype int16\n\n/// 32-bit signed integer.\ntype int32\n\n/// 64-bit signed integer.\ntype int64\n\n/// A Unicode code point.\ntype rune\n\n/// Unsigned integer (platform-dependent size).\ntype uint\n\n/// 8-bit unsigned integer.\ntype uint8\n\n/// 16-bit unsigned integer.\ntype uint16\n\n/// 32-bit unsigned integer.\ntype uint32\n\n/// 64-bit unsigned integer.\ntype uint64\n\n/// Unsigned integer large enough to hold a pointer.\ntype uintptr\n\n/// Alias for `uint8`, used for raw byte data.\ntype byte\n\n/// 32-bit floating-point number.\ntype float32\n\n/// 64-bit floating-point number.\ntype float64\n\n/// Complex number with `float32` real and imaginary parts.\ntype complex64\n\n/// Complex number with `float64` real and imaginary parts.\ntype complex128\n\n/// A boolean value: `true` or `false`.\ntype bool\n\n/// A UTF-8 encoded string.\ntype string\n\nimpl string {\n /// Returns the number of bytes in the string.\n fn length(self) -> int\n\n /// Returns `true` if the string has length zero.\n fn is_empty(self) -> bool\n\n /// Returns `true` if the string contains the given substring.\n fn contains(self, substr: string) -> bool\n\n /// Splits the string around each occurrence of `sep` and returns the substrings.\n fn split(self, sep: string) -> Slice<string>\n\n /// Returns `true` if the string starts with `prefix`.\n fn starts_with(self, prefix: string) -> bool\n\n /// Returns `true` if the string ends with `suffix`.\n fn ends_with(self, suffix: string) -> bool\n\n /// Returns the byte at index `i`.\n fn byte_at(self, i: int) -> byte\n\n /// Returns the rune at index `i`.\n fn rune_at(self, i: int) -> rune\n}\n\n// -----------------------\n// Compound types\n// -----------------------\n\n/// A value that may or may not be present.\n///\n/// Example:\n/// let maybe_name = Some(\"alice\")\n/// let fallback = maybe_name.unwrap_or(\"unknown\")\n/// let mapped = maybe_name.map(|s| s.length())\nenum Option<T> {\n Some(T),\n None,\n}\n\nimpl<T> Option<T> {\n /// Returns `true` if the option contains a value.\n fn is_some(self) -> bool\n\n /// Returns `true` if the option is `None`.\n fn is_none(self) -> bool\n\n /// Returns the contained value, or `default` if `None`.\n fn unwrap_or(self, default: T) -> T\n\n /// Returns the contained value, or computes it from `f` if `None`.\n fn unwrap_or_else(self, f: fn() -> T) -> T\n\n /// Transforms the contained value by applying `f`,\n /// or returns `None` if `None`.\n fn map<U>(self, f: fn(T) -> U) -> Option<U>\n\n /// Returns `default` if the option is `None`, otherwise applies\n /// `f` to the contained value.\n fn map_or<U>(self, default: U, f: fn(T) -> U) -> U\n\n /// Computes a default using `default` if `None`, or applies `f`\n /// to the contained value.\n fn map_or_else<U>(self, default: fn() -> U, f: fn(T) -> U) -> U\n\n /// Returns `None` if the option is `None`, otherwise calls `f`\n /// with the contained value and returns the result.\n fn and_then<U>(self, f: fn(T) -> Option<U>) -> Option<U>\n\n /// Returns the option if it is `Some`, otherwise calls `f`.\n fn or_else(self, f: fn() -> Option<T>) -> Option<T>\n\n /// Returns `Some(value)` if `pred` returns `true`, or `None` otherwise.\n fn filter(self, pred: fn(T) -> bool) -> Option<T>\n\n /// Takes the value out of the option, leaving `None` in its place.\n fn take(self: Ref<Option<T>>) -> Option<T>\n\n /// Transforms `Option<T>` into `Result<T, E>`, mapping `Some(v)`\n /// to `Ok(v)` and `None` to `Err(err)`.\n fn ok_or<E>(self, err: E) -> Result<T, E>\n\n /// Transforms `Option<T>` into `Result<T, E>`, mapping `Some(v)`\n /// to `Ok(v)` and `None` to `Err(f())`.\n fn ok_or_else<E>(self, f: fn() -> E) -> Result<T, E>\n\n /// Zips two options into an option of a tuple.\n /// Returns `Some((a, b))` if both are `Some`, otherwise `None`.\n fn zip<U>(self, other: Option<U>) -> Option<(T, U)>\n}\n\nimpl<U> Option<Option<U>> {\n /// Converts `Option<Option<U>>` into `Option<U>`.\n fn flatten(self) -> Option<U>\n}\n\n/// A result that is either a success (`Ok`) or a failure (`Err`).\n///\n/// Example:\n/// let res = Ok(42)\n/// let value = res.unwrap_or(0)\n/// let doubled = res.map(|x| x * 2)\nenum Result<T, E> {\n Ok(T),\n Err(E),\n}\n\nimpl<T, E> Result<T, E> {\n /// Returns `true` if the result is `Ok`.\n fn is_ok(self) -> bool\n\n /// Returns `true` if the result is `Err`.\n fn is_err(self) -> bool\n\n /// Converts to `Option<T>`, discarding the error if any.\n fn ok(self) -> Option<T>\n\n /// Converts to `Option<E>`, discarding the success value if any.\n fn err(self) -> Option<E>\n\n /// Returns the contained `Ok` value, or `default` if `Err`.\n fn unwrap_or(self, default: T) -> T\n\n /// Returns the contained `Ok` value, or computes it by calling `f` with the `Err` value.\n fn unwrap_or_else(self, f: fn(E) -> T) -> T\n\n /// Transforms the `Ok` value by applying `f`, leaving `Err` unchanged.\n fn map<U>(self, f: fn(T) -> U) -> Result<U, E>\n\n /// Transforms the `Err` value by applying `f`, leaving `Ok` unchanged.\n fn map_err<F>(self, f: fn(E) -> F) -> Result<T, F>\n\n /// Returns `default` if `Err`, otherwise applies `f` to the `Ok` value.\n fn map_or<U>(self, default: U, f: fn(T) -> U) -> U\n\n /// Calls `f` with the `Ok` value, leaving `Err` unchanged.\n fn and_then<U>(self, f: fn(T) -> Result<U, E>) -> Result<U, E>\n\n /// Calls `f` with the `Err` value, leaving `Ok` unchanged.\n fn or_else<F>(self, f: fn(E) -> Result<T, F>) -> Result<T, F>\n}\n\n/// A result from an operation where both a value and an error may be\n/// simultaneously meaningful. Used for Go functions like `io.Reader.Read`\n/// where `(n > 0, io.EOF)` means \"n bytes were read and the stream ended.\"\n///\n/// Unlike `Result`, the `?` operator is not supported on `Partial`.\n/// Use `match` to handle all three cases explicitly.\nenum Partial<T, E> {\n Ok(T),\n Err(E),\n Both(T, E),\n}\n\nimpl<T, E> Partial<T, E> {\n /// Returns `true` if this is `Ok`.\n fn is_ok(self) -> bool\n\n /// Returns `true` if this is `Err`.\n fn is_err(self) -> bool\n\n /// Returns `true` if this is `Both`.\n fn is_both(self) -> bool\n\n /// Returns `Some(value)` if `Ok` or `Both`, otherwise `None`.\n fn ok(self) -> Option<T>\n\n /// Returns `Some(error)` if `Err` or `Both`, otherwise `None`.\n fn err(self) -> Option<E>\n\n /// Returns the value if `Ok` or `Both`, otherwise `default`.\n fn unwrap_or(self, default: T) -> T\n\n /// Returns the value if `Ok` or `Both`, otherwise `f(error)`.\n fn unwrap_or_else(self, f: fn(E) -> T) -> T\n\n /// Transforms the value. `Ok(v)` becomes `Ok(f(v))`,\n /// `Both(v, e)` becomes `Both(f(v), e)`, `Err(e)` is unchanged.\n fn map<U>(self, f: fn(T) -> U) -> Partial<U, E>\n\n /// Transforms the error. `Err(e)` becomes `Err(f(e))`,\n /// `Both(v, e)` becomes `Both(v, f(e))`, `Ok(v)` is unchanged.\n fn map_err<F>(self, f: fn(E) -> F) -> Partial<T, F>\n}\n\n/// A growable, indexable sequence of elements. Equivalent to Go\'s `[]T`.\n///\n/// Example:\n/// let items = [1, 2, 3]\n/// let more = items.append(4, 5)\n/// let value = items.get(0).unwrap_or(0)\ntype Slice<T>\n\nimpl<T> Slice<T> {\n /// Creates a new empty slice.\n fn new() -> Slice<T>\n\n /// Returns the number of elements in the slice.\n fn length(self) -> int\n\n /// Returns `true` if the slice contains no elements.\n fn is_empty(self) -> bool\n\n /// Returns the capacity of the slice.\n fn capacity(self) -> int\n\n /// Returns the element at `index`, or `None` if out of bounds.\n fn get(self, index: int) -> Option<T>\n\n /// Returns a new slice with the given elements appended.\n fn append(self, elements: VarArgs<T>) -> Slice<T>\n\n /// Returns a new slice with all elements from `other` appended.\n fn extend(self, other: Slice<T>) -> Slice<T>\n\n /// Copies elements from `src` into this slice. Returns the number of elements copied.\n fn copy_from(self, src: Slice<T>) -> int\n\n /// Returns a new slice containing only elements for which `f` returns `true`.\n fn filter(self, f: fn(T) -> bool) -> Slice<T>\n\n /// Returns a new slice with `f` applied to each element.\n fn map<U>(self, f: fn(T) -> U) -> Slice<U>\n\n /// Returns `true` if the slice contains `value`.\n fn contains(self, value: T) -> bool\n\n /// Reduces the slice to a single value by applying `f` to each element\n /// with an accumulator, starting from `accumulator`.\n fn fold<U>(self, accumulator: U, f: fn(U, T) -> U) -> U\n\n /// Returns the first element for which `predicate` returns `true`, or `None`.\n fn find(self, predicate: fn(T) -> bool) -> Option<T>\n\n /// Returns `true` if any element satisfies `f`.\n fn any(self, f: fn(T) -> bool) -> bool\n\n /// Returns `true` if all elements satisfy `f`.\n fn all(self, f: fn(T) -> bool) -> bool\n\n /// Returns an enumerated slice for indexed iteration.\n fn enumerate(self) -> EnumeratedSlice<T>\n\n /// Returns a shallow copy of the slice.\n fn clone(self) -> Slice<T>\n}\n\n/// A slice paired with element indices, returned by `Slice.enumerate()`.\n/// Supports `for (i, v) in` iteration and chaining methods like `filter`, `map`, `fold`, and `find`.\ntype EnumeratedSlice<T>\n\nimpl<T> EnumeratedSlice<T> {\n fn filter(self, f: fn((int, T)) -> bool) -> Slice<(int, T)>\n\n fn map<U>(self, f: fn((int, T)) -> U) -> Slice<U>\n\n fn fold<U>(self, accumulator: U, f: fn(U, (int, T)) -> U) -> U\n\n fn find(self, f: fn((int, T)) -> bool) -> Option<(int, T)>\n}\n\nimpl Slice<string> {\n /// Joins the elements with `sep` between each pair.\n fn join(self, sep: string) -> string\n}\n\n/// A map from keys to values. Equivalent to Go\'s `map[K]V`.\n///\n/// Example:\n/// let m = Map.new<string, int>()\n/// m[\"key\"] = 42\n/// let value = m.get(\"key\").unwrap_or(0)\ntype Map<K, V>\n\nimpl<K, V> Map<K, V> {\n /// Creates a new empty map.\n fn new() -> Map<K, V>\n\n /// Returns the number of entries in the map.\n fn length(self) -> int\n\n /// Returns `true` if the map contains no entries.\n fn is_empty(self) -> bool\n\n /// Returns the value for `key`, or `None` if not present.\n fn get(self, key: K) -> Option<V>\n\n /// Removes the entry for `key`.\n fn delete(self, key: K)\n\n /// Creates a map from a slice of key-value pairs.\n fn from(pairs: Slice<(K, V)>) -> Map<K, V>\n\n /// Returns a shallow copy of the map.\n fn clone(self) -> Map<K, V>\n}\n\n/// A reference (pointer) to a value of type `T`. Equivalent to Go\'s `*T`.\n/// Create with `&x`, dereference with `x.*`.\n/// Methods with `Ref<T>` receivers automatically take a reference at call sites.\n///\n/// Example:\n/// let x = 42\n/// let r = &x\n/// let value = r.*\ntype Ref<T>\n\n/// A channel for sending and receiving values between tasks. Equivalent to Go\'s `chan T`.\n///\n/// Example:\n/// let ch = Channel.new<int>()\n/// task { ch.send(42) }\n/// let value = ch.receive().unwrap_or(0)\ntype Channel<T>\n\nimpl<T> Channel<T> {\n /// Creates a new unbuffered channel.\n fn new() -> Channel<T>\n\n /// Creates a new buffered channel with the given capacity.\n fn buffered(capacity: int) -> Channel<T>\n\n /// Sends a value. Returns `true` if sent, `false` if the channel was closed.\n fn send(self, value: T) -> bool\n\n /// Receives a value from the channel, or `None` if closed.\n fn receive(self) -> Option<T>\n\n /// Splits the channel into a sender and receiver pair.\n fn split(self) -> (Sender<T>, Receiver<T>)\n\n /// Returns the number of elements currently in the channel buffer.\n fn length(self) -> int\n\n /// Returns `true` if the channel buffer is empty.\n fn is_empty(self) -> bool\n\n /// Returns the capacity of the channel buffer.\n fn capacity(self) -> int\n\n /// Closes the channel. Safe to call multiple times.\n fn close(self)\n}\n\n/// The sending half of a channel. Equivalent to Go\'s `chan<- T`.\n///\n/// Example:\n/// let (tx, rx) = Channel.new<int>().split()\n/// tx.send(42)\n/// tx.close()\ntype Sender<T>\n\nimpl<T> Sender<T> {\n /// Sends a value. Returns `true` if sent, `false` if the channel was closed.\n fn send(self, value: T) -> bool\n\n /// Returns the number of elements currently in the channel buffer.\n fn length(self) -> int\n\n /// Returns `true` if the channel buffer is empty.\n fn is_empty(self) -> bool\n\n /// Returns the capacity of the channel buffer.\n fn capacity(self) -> int\n\n /// Closes the channel. Safe to call multiple times.\n fn close(self)\n}\n\n/// The receiving half of a channel. Equivalent to Go\'s `<-chan T`.\n///\n/// Example:\n/// let (tx, rx) = Channel.new<int>().split()\n/// let value = rx.receive().unwrap_or(0)\ntype Receiver<T>\n\nimpl<T> Receiver<T> {\n /// Receives a value from the channel, or `None` if closed.\n fn receive(self) -> Option<T>\n\n /// Returns the number of elements currently in the channel buffer.\n fn length(self) -> int\n\n /// Returns the capacity of the channel buffer.\n fn capacity(self) -> int\n\n /// Returns `true` if the channel buffer is empty.\n fn is_empty(self) -> bool\n}\n\n/// A half-open range from `start` to `end` (exclusive).\n///\n/// Example:\n/// for i in 0..5 {\n/// fmt.Println(i)\n/// }\npub struct Range<T> {\n pub start: T,\n pub end: T,\n}\n\n/// A closed range from `start` to `end` (inclusive).\n///\n/// Example:\n/// for i in 0..=5 {\n/// fmt.Println(i)\n/// }\npub struct RangeInclusive<T> {\n pub start: T,\n pub end: T,\n}\n\n/// A range from `start` with no upper bound.\n///\n/// Example:\n/// for i in 0.. {\n/// if i >= 10 { break }\n/// }\npub struct RangeFrom<T> {\n pub start: T,\n}\n\n/// A range from the beginning up to `end` (exclusive).\n///\n/// Example:\n/// let first_three = items[..3]\npub struct RangeTo<T> {\n pub end: T,\n}\n\n/// A range from the beginning up to `end` (inclusive).\n///\n/// Example:\n/// let up_to_three = items[..=3]\npub struct RangeToInclusive<T> {\n pub end: T,\n}\n\n// -----------------------\n// Special types\n// -----------------------\n\n/// Represents Go\'s `any` type. Only usable in `.d.lis` typedef files.\n/// Use `assert_type` to narrow an `Unknown` value to a concrete type.\n///\n/// Example:\n/// let value: Unknown = get_any_value()\n/// let n = assert_type<int>(value)?\ntype Unknown\n\n/// Indicates a function never returns. Used for functions that panic or loop forever.\n///\n/// Example:\n/// fn fail(msg: string) -> Never {\n/// panic(msg)\n/// }\ntype Never\n\n/// Zero or more arguments of type `T`. Only valid as the last parameter\n/// of a function. Corresponds to Go\'s `...T` syntax.\n///\n/// Example:\n/// fn sum(numbers: VarArgs<int>) -> int\ntype VarArgs<T>\n\n/// A value captured from a `recover` block after a panic.\n///\n/// Example:\n/// let result = recover { panicking_function() }\n/// match result {\n/// Ok(value) => fmt.Println(value),\n/// Err(pv) => fmt.Println(pv.message()),\n/// }\nstruct PanicValue {}\n\nimpl PanicValue {\n /// Returns the panic message string.\n fn message(self) -> string\n\n /// Returns the panic value as an `error`, if it implements the error interface.\n fn as_error(self) -> Option<error>\n\n /// Returns the stack trace at the point of the panic.\n fn stack_trace(self) -> string\n}\n\n/// The built-in error interface implemented by all error types.\n///\n/// Example:\n/// match fallible_call() {\n/// Ok(value) => fmt.Println(value),\n/// Err(err) => fmt.Println(err.Error()),\n/// }\ninterface error {\n fn Error() -> string\n}\n\n// -----------------------\n// Functions\n// -----------------------\n\n/// Type assertion for Go interop. Equivalent to Go\'s `v, ok := x.(T)`.\n/// Narrows an `Unknown` value to a concrete type `T`.\n/// Returns `Some(value)` if the runtime type matches, `None` otherwise.\n///\n/// Example:\n/// let value: Unknown = get_any_value()\n/// let n = assert_type<int>(value)?\nfn assert_type<T>(value: Unknown) -> Option<T>\n\n/// Constructs a complex number from real and imaginary parts.\nfn complex(r: float64, i: float64) -> complex128\n\n/// Returns the real part of a complex number.\nfn real(c: complex128) -> float64\n\n/// Returns the imaginary part of a complex number.\n#[go(\"imag\")]\nfn imaginary(c: complex128) -> float64\n\n/// Terminates the program with the given value.\n///\n/// Example:\n/// panic(\"something went wrong\")\n/// panic(err)\nfn panic(msg: Unknown) -> Never\n";