Jupyter kernel and REPL for the Aiken smart contract programming language
This project provides two main tools for interactive Aiken development:
- iaiken (interactive Aiken) - A Jupyter kernel that allows running Aiken code in Jupyter notebooks (depends on
aiken-repl
). - aiken-repl - A standalone REPL (Read-Eval-Print Loop) for interactive Aiken development.
Both tools leverage Aiken's existing compilation infrastructure to provide real-time type checking and code evaluation.
- Basic Jupyter integration - This implementation covers all the basic Jupyter protocol messages
- Definition Persistence - Define functions, constants, and types that persist across evaluations
- Type Information - Display both values and their types for rich feedback
- Rich Error Reporting - Rich error reporting with source code context
- Interactive Shell - Standalone REPL with rustyline for line editing
- Context Management - View and reset current evaluation context
- Special Commands - Built-in commands (
:help
,:quit
,:reset
,:context
) - History Support - Command history with up/down arrows
- Context Introspection - View current definitions and context state
- Redefinition Support - Redefine functions and constants dynamically
- Jupyter Kernel:
nix profile install github:rober-m/iaiken#iaiken
- REPL:
nix profile install github:rober-m/iaiken#aiken-repl
- Prerequisites:
- Rust 1.88.0 or later
- Jupyter Notebook or Labs (for
iaiken
)
- Clone the repo:
git clone https://github.com/rober-m/iaiken
cd
into the repository:cd iaiken
- Install the desired package:
- Jupyter Kernel:
cargo install --path crates/iaiken
- REPL:
cargo install --path crates/aiken-repl
- Jupyter Kernel:
- Install the kernel spec in Jupyter:
iaiken --install
- Start Jupyter:
jupyter notebook
# or
jupyter lab
-
Create a new notebook and select "Aiken" as the kernel
-
Start writing Aiken code in cells:
pub fn fibonacci(n: Int) -> Int {
if n <= 1 {
n
} else {
fibonacci(n - 1) + fibonacci(n - 2)
}
}
fibonacci(10)
Run the standalone REPL:
aiken-repl
Interactive session example:
🎯 Aiken REPL
Evaluate Aiken expressions or definitions. Use :quit to exit and :help to view all commands
λ> 1 + 2
3 : Int
λ> pub const my_number = 42
my_number : Int
λ> my_number * 2
84 : Int
λ> :help
🛟 Aiken REPL Help
Special commands:
:help, :h - Show this help
:quit, :q - Exit the REPL
:reset - Clear all definitions and restart
:context, :ctx - Show current context info
...
Uninstall kernel:
iaiken --uninstall # Remove the kernel spec
nix profile remove iaiken
# or
cargo uninstall iaiken
Uninstall REPL
nix profile remove aiken-repl
# or
cargo uninstall aiken-repl
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
Licensed under the Apache License, Version 2.0. See LICENSE for details.