refactor
This skill should be used when the user asks to "refactor", "extract function", "rename", "improve code quality", "reduce duplication", or "remove code smell". Supports Lean 4 and general refactoring patterns.
SKILL.md
| Name | refactor |
| Description | This skill should be used when the user asks to "refactor", "extract function", "rename", "improve code quality", "reduce duplication", or "remove code smell". Supports Lean 4 and general refactoring patterns. |
Ziku
A functional programming language exploring the duality between data and codata.
Features
- Pattern matching for data types
- Copattern matching for codata types using
#(self-reference) - First-class control with
label/goto - Hindley-Milner type inference with let-polymorphism
- Scheme backend for compilation to Chez Scheme
Quick Start
Docker (Recommended)
No local dependencies required:
docker build -t ziku . # Build image
docker run --rm -it ziku lake exe ziku # Run REPL
docker run --rm ziku # Run tests
Native
Requires Lean 4 and Chez Scheme:
lake build # Build
lake exe ziku # Run REPL
make -j4 test-parallel # Run tests
Examples
// Arithmetic and let bindings
let x = 10 in x + 1
// Functions
let double = \x => x * 2 in double 5
// Recursion
let rec factorial = \n =>
if n == 0 then 1
else n * factorial (n - 1)
in factorial 5
// Codata: define by behavior, not construction
// #.x => 10 means "when .x is accessed, return 10"
let point = { #.x => 10, #.y => 20 } in
point.x + point.y
// Callable codata (functions are codata!)
// #(x) => ... means "when called with x, return ..."
let square = { #(x) => x * x } in
square(5)
// Early return with label/goto
label done {
if condition then goto(result, done)
else continue
}
Documentation
- Getting Started - Installation and first steps
- Tutorial - Learn Ziku step by step
- Reference - Complete language reference
- Internals - Implementation details
- Development Workflow - Our GitHub-First development process
For Developers
Dependency Management
This project uses Renovate for automated dependency updates.
Renovate Setup (for maintainers):
-
Create a GitHub App
GitHub Settings → Developer settings → GitHub Apps → New GitHub App
Required settings:
- GitHub App name:
renovate-ziku(or any name) - Homepage URL:
https://github.com/takoeight0821/ziku - Webhook: Uncheck "Active"
Repository permissions (set all of the following):
- Checks: Read and write
- Contents: Read and write
- Commit statuses: Read and write
- Issues: Read and write
- Pull requests: Read and write
- Workflows: Read and write
- Metadata: Read only (auto-set)
After creation:
- Note the App ID (needed later)
- Click Generate a private key to download the
.pemfile
- GitHub App name:
-
Install the App to the repository
From the GitHub App page:
- Install App → Only select repositories → Select
takoeight0821/ziku - Get the Installation ID from the URL after installation
- Example:
12345678fromhttps://github.com/settings/installations/12345678
- Example:
- Install App → Only select repositories → Select
-
Add secrets to GitHub Actions
Repository Settings → Secrets and variables → Actions → New repository secret:
RENOVATE_APP_ID: The App ID from step 1RENOVATE_APP_PRIVATE_KEY: The entire contents of the downloaded.pemfile
-
Verify
Actions → Renovate → Run workflow to trigger manually
Auto-updated dependencies:
- GitHub Actions (weekly, Mondays 9:00 UTC)
- Nix flake inputs (nixpkgs, flake-utils)
- Git submodules
- Lean toolchain
- Lake dependencies
See CLAUDE.md for detailed dependency management information.
Background
Ziku is inspired by "Grokking the Sequent Calculus" (ICFP 2024), implementing a λμμ̃-calculus based intermediate representation that makes the duality between data and codata explicit.
License
See LICENSE file.