RepositoryJuliaCACanada
Roger-luo

Roger-luo/Moshi.jl

nextgen MLStyle: Generic Algebraic Data Type + Pattern Match

114stars
15forks
7issues
1views

Moshi

CI codecov

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 @derive from 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

Moshi is a   Julia Language   package. To install Moshi, please open Julia's interactive session (known as REPL) and press ] key in the REPL to use the package mode, then type the following command

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

benchmark

License

MIT License

Similar Projects

Discover other similar projects and AI models.

RepositoryJulia
MasonProtter/SumTypes.jl

An implementation of sum types in Julia

122
Nov 11, 2026
RepositoryC
hirrolot/datatype99

Algebraic data types for C99

1.5k
Mar 17, 2025
RepositoryRust
adam-mcdaniel/sage

A programming language that's wise beyond its bytes!🌱🌿🪴

559
May 18, 2026
RepositoryElixir
vic/expat

Reusable, composable patterns across Elixir libraries

175
Jul 15, 2025
RepositoryC#
mknejp/dotvariant

A type-safe and space-efficient sum type for C# (comparable to discriminated unions in C or C++)

73
Jun 30, 2026
RepositoryTypeScript
openclaw/openclaw

The AI that really does things. Any OS. Any Platform. The lobster way. 🦞

395.6k
Dec 2, 2026
Repository
jwasham/coding-interview-university

A complete computer science study plan to become a software engineer.

365.2k
Nov 7, 2026
RepositoryTypeScript
firecrawl/firecrawl

Firecrawl is the knowledge infrastructure to make your agents smarter. It connects your agents to the web, and to Alexandria, our library of everything else.

216.1k
Dec 3, 2026
Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
156.6M
Jun 1, 2026