Skip to content

Quick Start

Chloë Strainge edited this page Oct 14, 2026 · 1 revision

Quick start

Use shelly in a terminal, or save a program as hello.shy and run shelly hello.shy. The standard library is bundled with the executable.

Values and a function

A trip planner can keep distance and price numeric until it needs to display them:

fn fare($kilometers: Float, $price: Float): Float
{
    $kilometers * $price
}
let $cost: Float = fare 8 1.5
echo "Estimated fare: ${cost}"
Estimated fare: 12.0

The Integer 8 widens to Float because the parameter requires it. Strings do not silently become numbers. Function results are values; printed output is a separate channel.

Work through several values

fn discount($price: Integer): Integer { $price - 5 }
let $prices: [Integer]
[25, 40, 60] | discount | $prices
echo $prices...
20 35 55

The function receives each item automatically because no explicit arguments were written in that stage. Pipelines also support explicit $ placement.

Use a command

External programs are called in the usual shell style:

git status
cargo build --locked

Arguments such as status and build are literal words. Parentheses request a nested call. Assigning a process returns its status; use redirection when you want its output:

let $message: String
let $status = /usr/bin/printf "ready\n" -> $message
echo $message.trim $status
ready ExecResult(0)

Build a small model

struct Parcel { pub label: String, pub weight: Float }
fn Parcel::shipping(): Float { $self.weight * 2.5 }
let $parcel = Parcel(label: "books", weight: 4)
echo $parcel.label $parcel.shipping
books 10.0

Move reusable definitions into a module and mark its interface with pub. Modules shows a two-file program.


Related: Language basics · Pipelines · Modules

Clone this wiki locally