Hypershell examples
These pages walk through the runnable programs in the Hypershell repository, one program per page. Hypershell is a shell-scripting language whose programs are Rust types, built with Context-Generic Programming (CGP), a Rust library that lets each application choose an implementation. Each page runs a program, explains how its wiring produces what it prints, and names the CGP pattern it shows, so the pages work as short tutorials on those patterns.
The pages are in the order they teach. Each stands alone, but a reader new to Hypershell should
start with hello, since the later pages build on the ideas it introduces.
New to CGP?
These pages explain Hypershell's code without deriving CGP from first principles. The Hello World tutorial introduces CGP in a few minutes, and Type-level DSLs explains the technique Hypershell is built on with a much smaller language. Neither is required reading; each page links what it relies on.
Running an example
Clone the repository and run an example from its root with cargo run --example <name>. The
repository selects nightly Rust and the new trait solver itself; see the project
overview. Most examples also need the network and some common command-line
tools, which each page lists.
The examples
The first two programs run commands with no network access:
hello—echo hello world!, run on a context, the type a program runs on, whose whole definition is one line of wiring.hello_name— a program that reads a runtime value from a field of its context.
The next three are one pipeline written three ways, each replacing more of the shell with native stages:
http_checksum_cli—curl | sha256sum | cutas three streaming commands.http_checksum_client—curlreplaced by a native HTTP request.http_checksum_native— every stage native, from a language extended with checksums.
The rest show the language's other parts:
nix_manual— a static URL and an argument list that mixes literals and fields.save_webpage— a streaming download written to a file.github_issues— a URL built from fields, a request header, and JSON decoded into a Rust type.rust_playground— a program whose input and output are Rust values.bluesky— a pipeline that streams until it is stopped.bluesky_websocket— the same feed read by a WebSocket stage added to one context.
Two more programs in the repository, parallel_compare and compare_and_branch, add control syntax
that runs whole programs as operands. Their pages are still being written.
Where to go next
- Architecture: the design behind every example, one idea per page.
- Writing a program: the steps the examples share, as a guide.
An AI agent wrote this page using the CGP knowledge base. Its content was verified against the project's source. See How AI is used in this project.