Moshi.jl
nextgen MLStyle: Generic Algebraic Data Type + Pattern Match
Install / Use
/learn @Roger-luo/Moshi.jlREADME
Moshi
Moshi is the pattern in Chinese (模式). This package is the refactor of MLStyle with
- more correct pattern language for pattern match with
@match - type-stable algebra data type/tagged union with generics via
@data - traits, derive macro
@derivefrom rust
[!IMPORTANT]
This project is in the early stage of development. The macro syntax has been iterated across several packages including Expronicon, MLStyle. The syntax are mostly stable. However, the API and features are subject to change.
Installation
<p> Moshi is a <a href="https://julialang.org"> <img src="https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia.ico" width="16em"> Julia Language </a> package. To install Moshi, please <a href="https://docs.julialang.org/en/v1/manual/getting-started/">open Julia's interactive session (known as REPL)</a> and press <kbd>]</kbd> key in the REPL to use the package mode, then type the following command </p>pkg> add Moshi
Quick Example
Here is a quick example of defining a simple algebraic data type:
using Moshi.Data: @data
@data Message begin
Quit
struct Move
x::Int
y::Int
end
Write(String)
ChangeColor(Int, Int, Int)
end
For pattern matching, if you already used MLStyle, the syntax is very similar:
using Moshi.Match: @match
@match [1.0, 2, 3] begin
[1, xs::Float64...] => xs
end
@match (1, 2.0, "a") begin
(1, x::Int, y::String) => x
(1, x::Real, y::String) => y
end
Benchmark
License
MIT License
Related Skills
node-connect
337.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.3kCommit, push, and open a PR
