Repository navigation
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.
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.
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.
External programs are called in the usual shell style:
git status
cargo build --lockedArguments 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)
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
Begin here
Values and expressions
- Language basics
- Variables and scope
- Numbers and logic
- Strings and paths
- Arrays
- Hash maps
- Ranges and iteration
- Control flow
- Match and type guards
Functions and types
- Functions and calls
- Closures and function types
- Methods and properties
- Structs
- Enums
- Named types and unions
- Conversions
- Types and properties
Shell and modules
- Pipelines
- Pipeline splits
- Pipeline formats
- Commands and exit status
- Redirection
- Environment and exported variables
- Modules and visibility
- Nested modules and directory packages
- Conditional imports and declarations
- Errors and cleanup
- Supervised processes and terminals
Library guides
- Standard library
- The implicit prelude
- Bytes, files, readers, and writers
- Explicit item streams
- JSON documents and typed mapping
- Sockets, DNS, and TLS
- HTTP clients
- HTTP servers
- Framing, server-sent events, and JSON-RPC
- Terminal colors, styles, and geometry
- Build an application console
Interactive use