| Crates.io | mutica |
| lib.rs | mutica |
| version | 0.2.5 |
| created_at | 2025-10-09 18:55:58.419389+00 |
| updated_at | 2025-11-12 16:13:11.985469+00 |
| description | Mutica programming language |
| homepage | |
| repository | https://github.com/sjrsjz/Mutica |
| max_upload_size | |
| id | 1876080 |
| size | 87,377 |
An experimental, statically-typed programming language based on a pure Continuation-Passing Style (CPS) core.
Mutica is an experimental, statically-typed functional programming language that uses Continuation-Passing Style (CPS) as its core computation model. Its primary innovation is an advanced constraint validation system built upon a coinductive core, enabling precise, structural type checks far beyond traditional subtyping.
<:) operator for checking type compatibility and validating complex invariants, governed by a purely syntactic set of rules.Maybe.neg and rot that manipulate the constraint validation process itself, enabling powerful type-level metaprogramming.arc-gc for efficient cycle detection and memory management.Ensure you have the Rust toolchain installed. Then, clone and build the project:
git clone https://github.com/yourusername/Mutica.git
cd Mutica
cargo build --release
# Run a single file using cargo
cargo run -- run examples/fib.mu
# Or use the compiled executable directly
./target/release/mutica run examples/fib.mu
// Integer
let x: int = 42;
// Character
let c: char = 'A';
// Tuple
let pair: (int, int) = (1, 2);
// Generalize Type
let value: (int | char) = 42;
// Specialize Type (used for records/structs)
let point: { x::int & y::int } = { x::1 & y::2 };
// Top Type (any)
let anything: any = 42; // `any` is the supertype of all conventional types
let _ = 42; // An underscore can be used directly to assert a type constraint
// A function that accepts an integer
let add_one: any = (x: int) => x + 1; // `=>` defines a function
// A recursive function using `rec`
let fib: any = rec f: (n: int) =>
match n
| eq 0 => 0
| eq 1 => 1
| _ => f(n - 1) + f(n - 2)
| panic; // Asserts that the match is exhaustive for the input `n: int`
is)The is operator is not traditional subtyping, but a check to see if a type fulfills the constraints of another.
// A value fulfills the constraint of its general type
1 is int // true
// A more specific record fulfills the constraint of a more general one
{ x::1 & y::2 } is { x::int } // true
// Define labeled constructors
let Just: any = T: any => Just::T;
let Nothing: any = Nothing::();
// Define the Maybe type using a union
let Maybe: any = T: any => (Just T | Nothing);
// Use pattern matching on labeled types
match some_maybe_value
| Just::(x: int) => x + 1
| Nothing::() => 0
| panic;
// Use intersection types to simulate a struct
let Point: any = (x_val: int, y_val: int) => { x::x_val & y::y_val };
let p: any = Point(3, 4);
// Deconstructuring
let x::(x_value: int) = p;
let y::(y_value: int) = p;
let fib: any = rec f: match
| eq 0 => 0
| eq 1 => 1
| n: int => f(n - 1) + f(n - 2)
| panic;
fib(10) // Computes the 10th Fibonacci number
let List: any = (T: any) => rec list: (() | T @ list);
let print_chars: any = rec print_chars: str: List(char) =>
match str
| () => ()
| (head: char) @ (tail: any) => (discard print!(head); print_chars(tail))
| panic;
print_chars("Hello, world!\n")
The Mutica compiler is written in Rust and uses the following libraries:
clap: for command-line argument parsing.lalrpop: for parsing the Mutica grammar.logos: for lexical analysis.ariadne: for generating beautiful error reports.arc-gc: for garbage collection.stacksafe: for stack safety.The compilation process consists of the following stages:
Type representation.Type is reduced to its normal form.Contributions are highly welcome! Please feel free to open an Issue to discuss ideas or submit a Pull Request with improvements.
This project is licensed under the MIT License — see the LICENSE file for details.