muro-lang.dev / docs
V
muro emit path.muro --backend v checks the book and writes <stem>.v beside it. The file is one module. It needs V 0.5.2 and no third-party module. v -cc gcc -prod accepts it.
muro emit half_ok.muro --backend vmodule main
import half_ok
fn main() {
println(half_ok.half(u64(4)))
}v -cc gcc -prod -o half .
./half
That prints 2. The file on disk is named after the stem (half_ok.v). The module clause is the stem lowercased, with a character outside [a-z0-9_] replaced by _. A leading digit gains an m_ prefix. A V keyword or a primitive type gains _k. --v-module NAME sets the clause. NAME matches ^[a-z][a-z0-9_]*$ and is not a V keyword. Other backends refuse the flag. Absent, the name comes from the stem.
Muro.emit_v/2 writes the same file and returns {:ok, [path]}. A refusal writes nothing and prints no path. mix muro.gen writes the file when an entry sets kind: :v. The target ends with .v and names no module.
What is emitted
Spec and evidence are omitted. An erased argument and a type index are omitted. A run is pub fn. run internal is a private function. A book with no run, no data, and no session is <file> has no run to emit. A book of data alone is the types.
The first line is // Code generated by muro <version>. DO NOT EDIT. The next comment is the book basename. Then module <name>.
| Muro | V |
|---|---|
Nat |
u64, checked |
Unit |
struct MuroUnit {} |
WBool |
bool |
U8, U32, U64, I64 |
u8, u32, u64, i64 |
Bytes, Slice |
[]u8 |
Opt a |
MuroOpt[T] |
a × b |
MuroPair[A, B] |
| a guarded stream |
MuroStream[S, E], forced at uncons |
data, only nullary constructors |
enum |
| one constructor, not recursive |
struct |
| several constructors, or a recursive type |
type T = A | B, one struct per constructor |
Nat addition that can overflow calls muro__nat_add. The sum panics with muro Nat overflow when it wraps. suc uses that check. A numeral above 2^64 - 1 is refused at emit with nat: numeral does not fit in u64. The library pred and minus stay saturating. A user plus whose body is the library pin is muro__nat_add. Any other plus is the recursion the book writes.
U8, U32, U64, and I64 follow Muro.Word. Wrapping addition, subtraction, and multiplication never rely on a host overflow. U8 and U32 widen to u64, and U64 and I64 call small helpers built from 32-bit halves, so the result is the same under -prod and -check-overflow. Right shift of I64 is arithmetic. The same holds for Nat addition, which checks before it adds. Checked addition, subtraction, and multiplication return MuroOpt. Division or remainder by zero is the none arm, and so is I64 division or remainder of the minimum by -1. A shift by a count at or past the width is 0. An arithmetic right shift of a negative I64 by that much fills with the sign.
A slice shares its bytes. A view is taken with unsafe, so V does not clone it. A run that builds bytes takes mut muro__out []u8 and appends to that caller buffer. Each run is marked // alloc: none or // alloc: boxed <type>. A book whose called runs are all alloc: none does not need the Boehm collector. v -gc none builds that image.
A session is a step function. One enum holds the states, including invalid, done, and stuck. init returns the start state. step takes the state, a direction, a payload kind, and a tag, and returns the next state, the action, and the origin of a refusal. A payload that is not an enum is refused. A jump into another session is refused.
A choreography, a keyed family, and a temporal formula are refused even when the book also has runs. The message is v: choreography in <name>, v: keyed family in <name>, or v: temporal formula in <name>. A book that is only a conformance or only a meeting is v: conformance in <name> or v: meeting in <name>. may fail is still c:mayfail. A term the image cannot represent is v: <construct> in <run>.
Names
A constructor struct starts with a capital letter. An enum field, a function name, and a struct field are snake case. Muro.Emit.Name spells z and Z as zz, _ as zu, and - as zd. A V keyword gains _k. A one-letter capital, which V would read as a type parameter, gains _k before that capital is applied.
Affinity
The checker already rejected a second use. The V file does not track grades.
Source on GitHub
· fetched from murolang/muro manual/