Skip to content

Latest commit

 

History

History
56 lines (45 loc) · 1.8 KB

File metadata and controls

56 lines (45 loc) · 1.8 KB

MoonBit Project

This is a MoonBit project.

Quick Commands

make           # all
make fmt       # format code
make check     # type check
make test      # run unit + playwright tests
moon test -u   # update snapshot tests
make info      # generate type definition files
make clean     # moon clean
make all       # clean+fmt+build+test+info
make trim      # trim examples wasm webapi.mjs

Project Structure

  • moon.mod.json - Module definition
  • moon.pkg - Package dependencies (per directory)
  • *.mbt - Source files
  • *_test.mbt - Blackbox test files
  • *_wbtest.mbt - Whitebox test files
  • *.mbt.md - Doc test files
  • *.mbti - Generated type interfaces (auto-generated by moon info)

Coding Convention

  • Each block is separated by ///|
  • Use moon ide commands for code navigation (prefer over grep)
  • Use moon doc '<Type>' to explore APIs before implementing
  • MoonBit code uses snake_case for variables/functions (lowercase only)
  • UpperCamelCase for types, enums, and enum variants
  • nobreak (not else) for functional for-loop exit values
  • No return needed — last expression is the return value
  • No try needed for error propagation — automatic (unlike Swift)
  • Type parameter comes after fn: fn[T] foo(x: T) -> T
  • Legacy function_name!(...) and function_name(...)? are deprecated

Tooling

  • moon fmt - format code
  • moon info - update generated package interfaces (.mbti)
  • moon test - run tests. Use moon test --update to update snapshots.
  • moon check --deny-warn - type check with warnings as errors
  • moon doc '<query>' - discover APIs (more accurate than grep)
  • moon ide peek-def <Symbol> - show symbol definition
  • moon ide find-references <Symbol> - find all references

Before Commit

make all