Tour of Myceta & Quickstart
Myceta is a statically typed, expression-oriented, graph-native language. Pure logic lives in functions (fn);
observable, incrementally recomputed workflow outputs live in named graph nodes.
1. Module Structure, Records & Functions
Every .myc source file begins with a module declaration followed by explicit imports for non-prelude modules,
type declarations, pure helper functions, and graph nodes:
module Geometry.Planar
type Point = { x: f64; y: f64 }
type Shape =
| Circle(f64)
| Rect((f64, f64))
fn distance(a: Point, b: Point) -> f64 = {
let dx = a.x - b.x;
let dy = a.y - b.y;
(dx * dx + dy * dy).sqrt()
}
fn area(s: Shape) -> f64 =
match s {
Circle(r) -> 3.141592653589793 * r * r
Rect((w, h)) -> w * h
}
node Origin = Point { x = 0.0; y = 0.0 }
node Target = Point { x = 3.0; y = 4.0 }
node Span = distance(Origin, Target)
Hindley-Milner and bidirectional expected-type inference keep local bindings concise: annotate types at public module boundaries (function signatures, exported nodes, and unit contracts) and let literal widths flow inward.
2. Physical Units & Quantities
Numeric carriers accept compile-time unit expressions in angle brackets (f64<m>, f64<kg*m/s^2>,
or explicitly dimensionless f64<>). Unit algebra is erased after type checking with zero boxing overhead:
module Mechanics.Kinematics
import Myceta.Units.Mechanics
quantity Force = Mass * Length / Time^2
fn kineticEnergy(mass: f64<kg>, v: f64<m/s>) -> f64<J> =
0.5 * mass * v * v
node CartEnergy: f64<J> = kineticEnergy(12.0<kg>, 3.5<m/s>)
3. Scoped Local Mutability (let, var, mut)
Inside function and node blocks, Myceta separates three distinct levels of local binding authority so readers and optimizers know immediately whether aliasing mutation can occur:
| Keyword | Rebinding Allowed | In-Place Container Mutation | Intended Use |
|---|---|---|---|
let | No | No | Default immutable value binding. |
var | Yes (creates new version) | No | Pure loop accumulators and stepwise updates without mutating prior snapshots. |
mut | Yes | Yes (scoped to block) | In-place array/buffer algorithms where local mutable storage is required. |
4. Inputs, Scenarios & Native Graph Tests
External parameters are declared with inputs, explored systematically via named scenario overrides,
and verified directly inside the language using test, expect, and validate blocks:
inputs LoadCase {
span: f64<m> = 10.0<m>
snowLoad: f64<N/m> = 12000.0<N/m>
}
node MaxMoment: f64<N*m> =
(@in.LoadCase.snowLoad * @in.LoadCase.span * @in.LoadCase.span) / 8.0
scenario HeavyWinter = LoadCase with { snowLoad = 22000.0<N/m> }
test MomentStaysWithinCapacity under scenarios [LoadCase, HeavyWinter] {
expect MaxMoment : OK with value <= 350000.0<N*m>
}