feat: rebuild website with full learning funnel
Website rebuilt from scratch based on analysis of 11 beloved language websites (Elm, Zig, Gleam, Swift, Kotlin, Haskell, OCaml, Crystal, Roc, Rust, Go). New website structure: - Homepage with hero, playground, three pillars, install guide - Language Tour with interactive lessons (hello world, types, effects) - Examples cookbook with categorized sidebar - API documentation index - Installation guide (Nix and source) - Sleek/noble design (black/gold, serif typography) Also includes: - New stdlib/json.lux module for JSON serialization - Enhanced stdlib/http.lux with middleware and routing - New string functions (charAt, indexOf, lastIndexOf, repeat) - LSP improvements (rename, signature help, formatting) - Package manager transitive dependency resolution - Updated documentation for effects and stdlib - New showcase example (task_manager.lux) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -320,6 +320,114 @@ fn example(): Int with {Fail} = {
|
||||
}
|
||||
```
|
||||
|
||||
### Sql (SQLite)
|
||||
|
||||
```lux
|
||||
fn example(): Unit with {Sql, Console} = {
|
||||
let conn = Sql.open("mydb.sqlite") // Open database file
|
||||
// Or: let conn = Sql.openMemory() // In-memory database
|
||||
|
||||
// Execute statements (returns row count)
|
||||
Sql.execute(conn, "CREATE TABLE users (id INTEGER, name TEXT)")
|
||||
Sql.execute(conn, "INSERT INTO users VALUES (1, 'Alice')")
|
||||
|
||||
// Query returns list of rows
|
||||
let rows = Sql.query(conn, "SELECT * FROM users")
|
||||
|
||||
// Query for single row
|
||||
let user = Sql.queryOne(conn, "SELECT * FROM users WHERE id = 1")
|
||||
|
||||
// Transactions
|
||||
Sql.beginTx(conn)
|
||||
Sql.execute(conn, "UPDATE users SET name = 'Bob' WHERE id = 1")
|
||||
Sql.commit(conn) // Or: Sql.rollback(conn)
|
||||
|
||||
Sql.close(conn)
|
||||
}
|
||||
```
|
||||
|
||||
### Postgres (PostgreSQL)
|
||||
|
||||
```lux
|
||||
fn example(): Unit with {Postgres, Console} = {
|
||||
let conn = Postgres.connect("postgres://user:pass@localhost/mydb")
|
||||
|
||||
// Execute statements
|
||||
Postgres.execute(conn, "INSERT INTO users (name) VALUES ('Alice')")
|
||||
|
||||
// Query returns list of rows
|
||||
let rows = Postgres.query(conn, "SELECT * FROM users")
|
||||
|
||||
// Query for single row
|
||||
let user = Postgres.queryOne(conn, "SELECT * FROM users WHERE id = 1")
|
||||
|
||||
Postgres.close(conn)
|
||||
}
|
||||
```
|
||||
|
||||
### Concurrent (Parallel Tasks)
|
||||
|
||||
```lux
|
||||
fn example(): Unit with {Concurrent, Console} = {
|
||||
// Spawn concurrent tasks
|
||||
let task1 = Concurrent.spawn(fn(): Int => expensiveComputation(1))
|
||||
let task2 = Concurrent.spawn(fn(): Int => expensiveComputation(2))
|
||||
|
||||
// Do other work while tasks run
|
||||
Console.print("Tasks spawned, doing other work...")
|
||||
|
||||
// Wait for tasks to complete
|
||||
let result1 = Concurrent.await(task1)
|
||||
let result2 = Concurrent.await(task2)
|
||||
|
||||
Console.print("Results: " + toString(result1) + ", " + toString(result2))
|
||||
|
||||
// Check task status
|
||||
if Concurrent.isRunning(task1) then
|
||||
Concurrent.cancel(task1)
|
||||
|
||||
// Non-blocking sleep
|
||||
Concurrent.sleep(100) // 100ms
|
||||
|
||||
// Yield to allow other tasks to run
|
||||
Concurrent.yield()
|
||||
|
||||
// Get active task count
|
||||
let count = Concurrent.taskCount()
|
||||
}
|
||||
```
|
||||
|
||||
### Channel (Inter-Task Communication)
|
||||
|
||||
```lux
|
||||
fn example(): Unit with {Concurrent, Channel, Console} = {
|
||||
// Create a channel for communication
|
||||
let ch = Channel.create()
|
||||
|
||||
// Spawn producer task
|
||||
let producer = Concurrent.spawn(fn(): Unit => {
|
||||
Channel.send(ch, 1)
|
||||
Channel.send(ch, 2)
|
||||
Channel.send(ch, 3)
|
||||
Channel.close(ch)
|
||||
})
|
||||
|
||||
// Consumer receives values
|
||||
match Channel.receive(ch) {
|
||||
Some(value) => Console.print("Received: " + toString(value)),
|
||||
None => Console.print("Channel closed")
|
||||
}
|
||||
|
||||
// Non-blocking receive
|
||||
match Channel.tryReceive(ch) {
|
||||
Some(value) => Console.print("Got: " + toString(value)),
|
||||
None => Console.print("No value available")
|
||||
}
|
||||
|
||||
Concurrent.await(producer)
|
||||
}
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
Native testing framework:
|
||||
@@ -360,6 +468,10 @@ fn main(): Unit with {Console} = {
|
||||
| Random | int, float, bool |
|
||||
| State | get, put |
|
||||
| Fail | fail |
|
||||
| Sql | open, openMemory, close, execute, query, queryOne, beginTx, commit, rollback |
|
||||
| Postgres | connect, close, execute, query, queryOne |
|
||||
| Concurrent | spawn, await, yield, sleep, cancel, isRunning, taskCount |
|
||||
| Channel | create, send, receive, tryReceive, close |
|
||||
| Test | assert, assertEqual, assertTrue, assertFalse |
|
||||
|
||||
## Next
|
||||
|
||||
Reference in New Issue
Block a user