+
Skip to content

rober-m/iaiken

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jupyter kernel and REPL for the Aiken smart contract programming language

This project provides two main tools for interactive Aiken development:

  1. iaiken (interactive Aiken) - A Jupyter kernel that allows running Aiken code in Jupyter notebooks (depends on aiken-repl).
  2. 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.

iaiken features

  • 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

aiken-repl features

  • 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

Installation

With Nix

  • Jupyter Kernel: nix profile install github:rober-m/iaiken#iaiken
  • REPL: nix profile install github:rober-m/iaiken#aiken-repl

From source

  1. Prerequisites:
    1. Rust 1.88.0 or later
    2. Jupyter Notebook or Labs (for iaiken)
  2. Clone the repo: git clone https://github.com/rober-m/iaiken
  3. cd into the repository: cd iaiken
  4. Install the desired package:
    • Jupyter Kernel: cargo install --path crates/iaiken
    • REPL: cargo install --path crates/aiken-repl

Usage

Jupyter Kernel

  1. Install the kernel spec in Jupyter:
iaiken --install
  1. Start Jupyter:
jupyter notebook
# or
jupyter lab
  1. Create a new notebook and select "Aiken" as the kernel

  2. 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)

Standalone REPL

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
...

Uninstalling

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

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

About

REPL and Jupyter Kernel for the Aiken programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载