42 lines
749 B
Markdown
42 lines
749 B
Markdown
## Basic hello world
|
|
|
|
```c
|
|
open std::io;
|
|
|
|
// const { io } = import!("std");
|
|
pub main := fn() -> () {
|
|
io.println("Hello, world");
|
|
io.Writer
|
|
iterator.map(color::Color::to_bytes)
|
|
};
|
|
```
|
|
|
|
## Structured data
|
|
|
|
```c
|
|
Color ::= Color { red: u8, green: u8, blue: u8 };
|
|
```
|
|
|
|
## Union types
|
|
|
|
```c
|
|
Result<T, E> ::= Ok (T) | Err (E);
|
|
|
|
Option<T> ::= Some (T) | None;
|
|
|
|
MaybeColor ::= SomeColor { red: u8, green: u8, blue: u8 } | None;
|
|
```
|
|
|
|
# Symbol Semantics
|
|
|
|
- `=` => Equal by assignment (or reassignment)
|
|
- `:=` => Equal by definition
|
|
- `::=` => Equal in structure or type
|
|
- `//` => in-line comment
|
|
- `///` => in-line doc comment
|
|
- `//!` => in-line module doc comment
|
|
- `|` => type union
|
|
|
|
## Classes
|
|
|
|
Same thing as a Haskell typeclass or Rust trait.
|