Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Indentation-based ClojureScript dialect in Rust and compiling to JavaScript ES Modules

NotificationsYou must be signed in to change notification settings

calcit-lang/calcit

Repository files navigation

Semantically a dialect of ClojureScript. Built with Rust. Compiles to JavaScript ES Modules.

Browse examples or alsotry WASM version online.

Core design:

  • Interpreter runs on Rust, extensible with Rust FFI
  • Persistent Data Structure
  • Structural Editor(with indentation-based syntax as a fallback)
  • Lisp macros, functional style
  • Compiles to JavaScript in ES Modules, JavaScript Interop
  • Hot code swapping friendly

InstallGitHub Release

Build and install with Rust:

# get Rustcurl --proto'=https' --tlsv1.2 -sSf https://sh.rustup.rs| sh# get Calcitcargo install calcit

3 binaries are installed:

  • calcit, the runtime and js compiler
  • caps, for downloading dependencies declared indeps.cirru
  • bundle_calcit, bundle code if you don't want to use Calcit Editor

To use Calcit in GitHub Actions, trysetup-cr.

Usage

Snippets evaluating:

creval'range 100'creval'thread-first 100 range (map $ \ * % %)'

Run with acompact.cirru:

cr compact.cirru -1# run only oncecr -1# by default, it picks `compact.cirru`cr# watch mode enabled by default

By default Calcit reads:init-fn and:reload-fn insidecompact.cirru configs. You may also specify functions,

cr --init-fn='app.main/main!' --reload-fn='app.main/reload!'

and even configure:entries incompact.cirru:

cr --entry server

JavaScript codegen

It compiles to JavaScript and runs in consistet semantics. However it might require a lot of JavaScript interop.

cr js# compile to js, also picks `compact.cirru` by defaultcr js --emit-path=out/# compile to js and save in `out/`

By default, js code is generated tojs-out/. You will need Vite or Node to run it, from an entry file:

import{main_$x_,reload_$x_}from"./js-out/app.main.mjs";main_$x_();// which corresponds to `main!` function in calcit

Calcit Editor & Bundler

InstallCalcit Editor and runct to launch editor server,which writescompact.cirru and.compact-inc.cirru on saving. Try launching example by cloningCalcit Workflow.

Read more inMinimal Calcit to learn how to code Calcit with a plain text editor.

Read more inRespo Calcit Workflow to learn to create an MVC webpage withRespo.

MCP (Model Context Protocol) Support

Calcit provides MCP server functionality for integration with AI assistants and development tools. The MCP server offers tools for:

  • Code Management: Read, write, and modify Calcit namespaces and definitions
  • Project Operations: Manage modules, dependencies, and configurations
  • Calcit Runner: Start/stop background runner processes with incremental updates
  • Documentation: Query API docs, reference materials, and dependency documentation

Incremental File Processing

When using the Calcit Runner through MCP:

  1. Start Runner: Usestart_calcit_runner to launch the background process. This automatically:

    • Creates a.calcit-tmp/ directory
    • Copies the currentcompact.cirru as a temporary baseline
  2. Generate Incremental Updates: After making changes to your code, usegenerate_calcit_incremental to:

    • Compare currentcompact.cirru with the temporary baseline
    • Generate a.compact-inc.cirru file with only the changes
    • Apply incremental updates to the running process
  3. Check Results: After generating the incremental file, always check the runner logs usinggrab_calcit_runner_logs to verify that updates were applied successfully.

This workflow enables efficient hot-reloading during development without restarting the entire application.

Modules

deps.cirru declares dependencies that need to download, which correspond to repositories on GitHub. Specify a branch or a tag:

{}  :calcit-version|0.9.11  :dependencies${}    |calcit-lang/memof|0.0.11    |calcit-lang/lilac|main

Runcaps to download. Sources are downloaded into~/.config/calcit/modules/. If a module containsbuild.sh, it will be executed mostly for compiling Rust dylibs.

:calcit-version helps in check version, and provides hints inCI environment.

To load modules, use:modules configuration andcompact.cirru(which normally generated fromcalcit.cirru):

:configs${}  :modules$[]|memof/compact.cirru|lilac/

Paths defined in:modules field are just loaded as files from~/.config/calcit/modules/,i.e.~/.config/calcit/modules/memof/compact.cirru.

Modules that ends with/s are automatically suffixedcompact.cirru since it's the default entry.

Development

I use these commands to run local examples:

# run tests in Rustcargo run --bin cr -- calcit/test.cirru -1# run tests in Node.jscargo run --bin cr -- calcit/test.cirru -1 js&& yarn try-js# run snippetcargo run --bin cr --eval'range 100'cr compact.cirru -1 ir# compiles intermediate representation into program-ir.cirru

Other tools:

Some resources:

License

MIT

About

Indentation-based ClojureScript dialect in Rust and compiling to JavaScript ES Modules

Topics

Resources

Stars

Watchers

Forks

Contributors8


[8]ページ先頭

©2009-2025 Movatter.jp