Learn
Find docs
part / StartOpenStartBegin with a small file, a few names, and one result.part / Core expressionsOpenCore expressionsRead values, calls, operators, functions, and small sequence expressions.part / DataOpenDataUse visible data shapes and match them directly.part / OrganizationOpenOrganizationMake names easy to find and reuse.part / TypesOpenTypesUse annotations, callable types, generics, and checks.part / AbstractionsOpenAbstractionsKeep data separate from behavior.part / Effects and runtimeOpenEffects and runtimeMake outside work visible at the call site.part / Advanced formsOpenAdvanced formsReach lower-level features after the core syntax is clear.chapter / StartOpenGetting startedMusi source files end in `.ms`. Start with one small file and run one command.chapter / StartOpenFirst programA Musi file reads from top to bottom. The last expression can be the result for direct file checks.chapter / StartOpenReading Musi codeFirst find names, imports, exports, and final expressions. Then read each body.chapter / StartOpenValues and
let`let` gives a name to a value. `export let` makes the name public.chapter / StartOpenCommentsUse comments for why, doc comments for public names, and names or types for what.chapter / StartOpenBlocks and expressionsUse parenthesized sequence expressions for local steps, and braces for structural forms.chapter / StartOpenMutationMutation is visible. Reassignment writes to an existing mutable place.chapter / Core expressionsOpenLiteralsLiterals create values directly. They do not call another name.chapter / Core expressionsOpenTuples and unitA tuple groups values by position. Unit means no useful value.chapter / Core expressionsOpenOperators`:=` writes, `=` compares, arrows describe callables, and pipelines pass values forward.chapter / Core expressionsOpenAssignment and equality`:=` stores a value. `=` checks equal values. `/=` checks different values.chapter / Core expressionsOpenMath and comparison`+`, `-`, `*`, `/`, and `%` compute numbers. `<`, `<=`, `>`, and `>=` compare them.chapter / Core expressionsOpenLogic and bits`and`, `or`, `xor`, and `not` combine checks. `shl` and `shr` shift integer bits.chapter / Core expressionsOpenPipelines and access`|>` passes a value forward. `.` reads fields. `.[index]` reads an ordered item.chapter / Core expressionsOpenType operators`:` annotates, `:?` tests a runtime type, and `:?>` casts.chapter / Core expressionsOpenCallable arrows`->` describes a callable type. `~>` describes an effectful callable. `=>` starts a lambda body.chapter / Core expressionsOpenRangesA range stores start and end information. Inclusivity belongs to the range value.chapter / Core expressionsOpenFunctionsFunctions are named values. Parameters and result types stay near the name.chapter / Core expressionsOpenLambdasA lambda starts with `\\`. This keeps it separate from tuples and grouped expressions.chapter / Core expressionsOpenCallsA call evaluates a callable value and passes arguments to it.chapter / Core expressionsOpenDot-callsA receiver call keeps the value being acted on at the front.chapter / DataOpenRecordsA record keeps related values together and names each field.chapter / DataOpenArrays and slicesArrays keep values in order. Slices let code talk about part of that order.chapter / DataOpenIndexing and fieldsDot access reads a field. Indexed access reads by position.chapter / DataOpenData definitions`data` creates a type-shaped value. Variants use `|`. Record fields use `;`.chapter / DataOpenPatternsPatterns let `match` read variants, fields, and simple values.chapter / DataOpenOption and resultOption means value or no value. Result means success or error.chapter / OrganizationOpenFilesA file is the first unit a reader opens. Keep it small and focused.chapter / OrganizationOpenPackagesA package gives files a home and declares how the project runs.chapter / OrganizationOpenImports and exports`export` shares a name. `import` brings shared names into a file.chapter / OrganizationOpenStandard libraryStandard library modules hold common data and helper functions.chapter / TypesOpenType annotationsA type annotation says what kind of value a name should hold.chapter / TypesOpenCallable typesCallable types describe functions and effectful calls.chapter / TypesOpenType inferenceMusi can infer many local types from the expression on the right.chapter / TypesOpenGenericsGenerics let code keep one shape while the item type changes.chapter / TypesOpenType tests and castsType tests ask about a type. Casts assert a type.chapter / TypesOpenOptional and fallible typesOptional and fallible types keep missing values and errors visible.chapter / AbstractionsOpenShapesA shape says which behavior a type must provide.chapter / AbstractionsOpenGiven valuesA given value says how a type follows a shape.chapter / AbstractionsOpenLawsA law states an expected rule for a shape or behavior.chapter / AbstractionsOpenContextual capabilitiesA contextual capability lets code ask for behavior without passing it by hand each time.chapter / Effects and runtimeOpenEffectsAn effect names an operation that asks for an answer from outside normal value flow.chapter / Effects and runtimeOpenAsk, answer, handle`ask` performs an effect operation. A handler can answer and resume.chapter / Effects and runtimeOpenRequirementsA requirement makes needed ability visible near the function.chapter / Effects and runtimeOpenRuntime modulesRuntime modules help code read values from the running environment.chapter / Effects and runtimeOpenFoundation and standard librarySome modules provide core names. Standard library modules provide common app tools.chapter / Advanced formsOpenAttributesAttributes add extra information to declarations.chapter / Advanced formsOpenNative and unsafe`native` declares a host edge. `unsafe` marks code that needs extra care.chapter / Advanced formsOpenQuote and syntax`quote` builds syntax. Splices insert known syntax pieces.chapter / Advanced formsOpenTemplates and splicesTemplates build text from fixed parts and values.chapter / Advanced formsOpenTesting and runningUse commands to check one file, check a package, and run tests.No matching docs yet. Try a command, type, effect, or operator.
Learn · Musi Book
This is the main book. It moves from your first file to syntax, data, types, effects, and commands.
Start
Open section
Begin with a small file, a few names, and one result.
Chapter»Getting startedMusi source files end in
.ms. Start with one small file and run one command.Chapter»First programA Musi file reads from top to bottom. The last expression can be the result for direct file checks.Chapter»Reading Musi codeFirst find names, imports, exports, and final expressions. Then read each body.Chapter»CommentsUse comments for why, doc comments for public names, and names or types for what.Chapter»Values and letlet gives a name to a value. export let makes the name public.Chapter»Blocks and expressionsUse parenthesized sequence expressions for local steps, and braces for structural forms.Chapter»MutationMutation is visible. Reassignment writes to an existing mutable place.Core expressions
Open section
Read values, calls, operators, functions, and small sequence expressions.
Chapter»LiteralsLiterals create values directly. They do not call another name.Chapter»Tuples and unitA tuple groups values by position. Unit means no useful value.Chapter»Operators
:= writes, = compares, arrows describe callables, and pipelines pass values forward.Chapter»Assignment and equality:= stores a value. = checks equal values. /= checks different values.Chapter»Math and comparison+, -, *, /, and % compute numbers. <, <=, >, and >= compare them.Chapter»Logic and bitsand, or, xor, and not combine checks. shl and shr shift integer bits.Chapter»Pipelines and access|> passes a value forward. . reads fields. .[index] reads an ordered item.Chapter»Type operators: annotates, :? tests a runtime type, and :?> casts.Chapter»Callable arrows-> describes a callable type. ~> describes an effectful callable. => starts a lambda body.Chapter»RangesA range stores start and end information. Inclusivity belongs to the range value.Chapter»FunctionsFunctions are named values. Parameters and result types stay near the name.Chapter»LambdasA lambda starts with \\. This keeps it separate from tuples and grouped expressions.Chapter»CallsA call evaluates a callable value and passes arguments to it.Chapter»Dot-callsA receiver call keeps the value being acted on at the front.Data
Open section
Use visible data shapes and match them directly.
Chapter»RecordsA record keeps related values together and names each field.Chapter»Arrays and slicesArrays keep values in order. Slices let code talk about part of that order.Chapter»Data definitions
data creates a type-shaped value. Variants use |. Record fields use ;.Chapter»Indexing and fieldsDot access reads a field. Indexed access reads by position.Chapter»Option and resultOption means value or no value. Result means success or error.Chapter»PatternsPatterns let match read variants, fields, and simple values.Organization
Open section
Make names easy to find and reuse.
Chapter»FilesA file is the first unit a reader opens. Keep it small and focused.Chapter»PackagesA package gives files a home and declares how the project runs.Chapter»Imports and exports
export shares a name. import brings shared names into a file.Chapter»Standard libraryStandard library modules hold common data and helper functions.Types
Open section
Use annotations, callable types, generics, and checks.
Chapter»Type annotationsA type annotation says what kind of value a name should hold.Chapter»Type inferenceMusi can infer many local types from the expression on the right.Chapter»Optional and fallible typesOptional and fallible types keep missing values and errors visible.Chapter»Callable typesCallable types describe functions and effectful calls.Chapter»GenericsGenerics let code keep one shape while the item type changes.Chapter»Type tests and castsType tests ask about a type. Casts assert a type.
Abstractions
Open section
Keep data separate from behavior.
Chapter»ShapesA shape says which behavior a type must provide.Chapter»Given valuesA given value says how a type follows a shape.Chapter»LawsA law states an expected rule for a shape or behavior.Chapter»Contextual capabilitiesA contextual capability lets code ask for behavior without passing it by hand each time.
Effects and runtime
Open section
Make outside work visible at the call site.
Chapter»EffectsAn effect names an operation that asks for an answer from outside normal value flow.Chapter»RequirementsA requirement makes needed ability visible near the function.Chapter»Ask, answer, handle
ask performs an effect operation. A handler can answer and resume.Chapter»Runtime modulesRuntime modules help code read values from the running environment.Chapter»Foundation and standard librarySome modules provide core names. Standard library modules provide common app tools.Advanced forms
Open section
Reach lower-level features after the core syntax is clear.
Chapter»AttributesAttributes add extra information to declarations.Chapter»Native and unsafe
native declares a host edge. unsafe marks code that needs extra care.Chapter»Quote and syntaxquote builds syntax. Splices insert known syntax pieces.Chapter»Templates and splicesTemplates build text from fixed parts and values.Chapter»Testing and runningUse commands to check one file, check a package, and run tests.