fix: C backend String functions, record type aliases, docs cleanup
- Add String.fromChar, chars, substring, toUpper, toLower, replace, startsWith, endsWith, join to C backend - Fix record type alias unification by adding expand_type_alias and unify_with_env functions - Update docs to reflect current implementation status - Clean up outdated roadmap items and fix inconsistencies - Add comprehensive language comparison document Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,10 @@ Lux should compile to native code with zero-cost effects AND compile to JavaScri
|
||||
| Component | Status |
|
||||
|-----------|--------|
|
||||
| Interpreter | Full-featured, all language constructs |
|
||||
| C Backend | Complete (functions, closures, pattern matching, lists, RC) |
|
||||
| JS Backend | Complete (full language, browser & Node.js, DOM, TEA) |
|
||||
| JIT (Cranelift) | Integer arithmetic only, ~160x speedup |
|
||||
| Targets | Native (via Cranelift JIT) |
|
||||
| Targets | Native (via C), JavaScript, JIT |
|
||||
|
||||
## Target Architecture
|
||||
|
||||
@@ -296,45 +298,33 @@ Tree increment(Tree tree) {
|
||||
|
||||
## Milestones
|
||||
|
||||
### v0.2.0 - C Backend (Basic)
|
||||
- [ ] Integer/bool expressions → C
|
||||
- [ ] Functions → C functions
|
||||
- [ ] If/else → C conditionals
|
||||
- [ ] Let bindings → C variables
|
||||
- [ ] Basic main() generation
|
||||
- [ ] Build with GCC/Clang
|
||||
### C Backend - COMPLETE
|
||||
- [x] Integer/bool expressions → C
|
||||
- [x] Functions → C functions
|
||||
- [x] If/else → C conditionals
|
||||
- [x] Let bindings → C variables
|
||||
- [x] Basic main() generation
|
||||
- [x] Build with GCC/Clang
|
||||
- [x] Strings → C strings
|
||||
- [x] Pattern matching → Switch/if chains
|
||||
- [x] Lists → Linked structures
|
||||
- [x] Closures
|
||||
- [x] Reference counting (lists, boxed values)
|
||||
|
||||
### v0.3.0 - C Backend (Full)
|
||||
- [ ] Strings → C strings
|
||||
- [ ] Records → C structs
|
||||
- [ ] ADTs → Tagged unions
|
||||
- [ ] Pattern matching → Switch/if chains
|
||||
- [ ] Lists → Linked structures
|
||||
- [ ] Effect compilation (basic)
|
||||
### JavaScript Backend - COMPLETE
|
||||
- [x] Basic expressions → JS
|
||||
- [x] Functions → JS functions
|
||||
- [x] Effects → Direct DOM/API calls
|
||||
- [x] Standard library (String, List, Option, Result, Math, JSON)
|
||||
- [x] DOM effect (40+ operations)
|
||||
- [x] Html module (type-safe HTML)
|
||||
- [x] TEA runtime (Elm Architecture)
|
||||
- [x] Browser & Node.js support
|
||||
|
||||
### v0.4.0 - Evidence Passing
|
||||
- [ ] Effect analysis
|
||||
- [ ] Evidence vector generation
|
||||
- [ ] Transform effect ops to direct calls
|
||||
- [ ] Handler compilation
|
||||
|
||||
### v0.5.0 - JavaScript Backend
|
||||
- [ ] Basic expressions → JS
|
||||
- [ ] Functions → JS functions
|
||||
- [ ] Effects → Direct DOM/API calls
|
||||
- [ ] No runtime bundle
|
||||
|
||||
### v0.6.0 - Reactive Frontend
|
||||
- [ ] Reactive primitives
|
||||
- [ ] Fine-grained DOM updates
|
||||
- [ ] Compile-time dependency tracking
|
||||
- [ ] Svelte-like output
|
||||
|
||||
### v0.7.0 - Memory Optimization
|
||||
- [ ] Reference counting insertion
|
||||
- [ ] Reuse analysis
|
||||
- [ ] FBIP detection
|
||||
- [ ] In-place updates
|
||||
### Remaining Work
|
||||
- [ ] Evidence passing for zero-cost effects
|
||||
- [ ] FBIP (Functional But In-Place) optimization
|
||||
- [ ] WASM backend (deprioritized)
|
||||
|
||||
## References
|
||||
|
||||
|
||||
@@ -124,22 +124,19 @@ String interpolation is fully working:
|
||||
- Escape sequences: `\{`, `\}`, `\n`, `\t`, `\"`, `\\`
|
||||
|
||||
#### 1.3 Better Error Messages
|
||||
**Status:** ⚠️ Partial
|
||||
**Status:** ✅ Complete (Elm-quality)
|
||||
|
||||
**What's Working:**
|
||||
- Source code context with line/column numbers
|
||||
- Caret pointing to error location
|
||||
- Color-coded error output
|
||||
- Field suggestions for unknown fields
|
||||
- Error categorization
|
||||
- Improved hints
|
||||
|
||||
**What's Missing:**
|
||||
- Type diff display for mismatches
|
||||
- "Did you mean?" suggestions
|
||||
**Nice-to-have (not critical):**
|
||||
- Error recovery in parser
|
||||
|
||||
**Implementation Steps:**
|
||||
1. Add Levenshtein distance for suggestions
|
||||
2. Implement error recovery in parser
|
||||
3. Add type diff visualization
|
||||
- Type diff visualization
|
||||
|
||||
### Priority 2: Effect System Completion
|
||||
|
||||
@@ -198,8 +195,10 @@ fn withRetry<E>(action: fn(): T with E, attempts: Int): T with E = ...
|
||||
- Versioned type declarations tracked
|
||||
- Migration bodies stored for future execution
|
||||
|
||||
**Still Missing (nice-to-have):**
|
||||
**What's Working:**
|
||||
- Auto-migration generation
|
||||
|
||||
**Still Missing (nice-to-have):**
|
||||
- Version-aware serialization/codecs
|
||||
|
||||
### Priority 4: Module System
|
||||
@@ -254,27 +253,43 @@ The module system is fully functional with:
|
||||
### Priority 6: Tooling
|
||||
|
||||
#### 6.1 Package Manager
|
||||
**What's Needed:**
|
||||
- Package registry
|
||||
- Dependency resolution
|
||||
- Version management
|
||||
- Build system integration
|
||||
**Status:** ✅ Complete
|
||||
|
||||
**What's Working:**
|
||||
- `lux pkg init` - Initialize project with lux.toml
|
||||
- `lux pkg add/remove` - Manage dependencies
|
||||
- `lux pkg install` - Install from lux.toml
|
||||
- Git and local path dependencies
|
||||
- Package registry (`lux registry`)
|
||||
- CLI commands (search, publish)
|
||||
|
||||
**Still Missing (nice-to-have):**
|
||||
- Version conflict resolution
|
||||
|
||||
#### 6.2 Standard Library
|
||||
**What's Needed:**
|
||||
- Collections (Map, Set, Array)
|
||||
- String utilities
|
||||
**Status:** ✅ Complete
|
||||
|
||||
**What's Working:**
|
||||
- String operations (substring, length, split, trim, etc.)
|
||||
- List operations (map, filter, fold, etc.)
|
||||
- Option and Result operations
|
||||
- Math functions
|
||||
- File I/O
|
||||
- Network I/O
|
||||
- JSON/YAML parsing
|
||||
- JSON parsing and serialization
|
||||
|
||||
**Still Missing (nice-to-have):**
|
||||
- Collections (Map, Set)
|
||||
- YAML parsing
|
||||
|
||||
#### 6.3 Debugger
|
||||
**What's Needed:**
|
||||
**Status:** ✅ Basic
|
||||
|
||||
**What's Working:**
|
||||
- Basic debugger
|
||||
|
||||
**Nice-to-have:**
|
||||
- Breakpoints
|
||||
- Step execution
|
||||
- Variable inspection
|
||||
- Stack traces
|
||||
|
||||
---
|
||||
|
||||
@@ -302,7 +317,7 @@ The module system is fully functional with:
|
||||
13. ~~**Idempotent verification**~~ ✅ Done - Pattern-based analysis
|
||||
14. ~~**Deterministic verification**~~ ✅ Done - Effect-based analysis
|
||||
15. ~~**Commutative verification**~~ ✅ Done - Operator analysis
|
||||
16. **Where clause enforcement** - Constraint checking (basic parsing done)
|
||||
16. ~~**Where clause enforcement**~~ ✅ Done - Property constraints
|
||||
|
||||
### Phase 5: Schema Evolution (Data)
|
||||
17. ~~**Type system version tracking**~~ ✅ Done
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
433
docs/LSP.md
Normal file
433
docs/LSP.md
Normal file
@@ -0,0 +1,433 @@
|
||||
# Lux Language Server Protocol (LSP)
|
||||
|
||||
Lux includes a built-in language server that provides IDE features for any editor that supports the Language Server Protocol.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Starting the LSP Server
|
||||
|
||||
```bash
|
||||
lux lsp
|
||||
```
|
||||
|
||||
The server communicates via stdio (stdin/stdout), following the standard LSP protocol.
|
||||
|
||||
## Supported Features
|
||||
|
||||
| Feature | Status | Description |
|
||||
|---------|--------|-------------|
|
||||
| Diagnostics | Full | Real-time parse and type errors |
|
||||
| Hover | Full | Type information and documentation |
|
||||
| Completions | Full | Context-aware code completion |
|
||||
| Go to Definition | Full | Jump to function/type definitions |
|
||||
| Formatting | CLI only | Code formatting via `lux fmt` (not exposed via LSP) |
|
||||
| Rename | Planned | Rename symbols |
|
||||
| Find References | Planned | Find all usages |
|
||||
|
||||
## Editor Setup
|
||||
|
||||
### VS Code
|
||||
|
||||
1. Install the Lux extension from the VS Code marketplace (coming soon)
|
||||
|
||||
2. Or configure manually in `settings.json`:
|
||||
```json
|
||||
{
|
||||
"lux.lspPath": "/path/to/lux",
|
||||
"lux.enableLsp": true
|
||||
}
|
||||
```
|
||||
|
||||
3. Or use a generic LSP client extension like [vscode-languageclient](https://github.com/microsoft/vscode-languageserver-node):
|
||||
|
||||
```json
|
||||
{
|
||||
"languageServerExample.serverPath": "lux",
|
||||
"languageServerExample.serverArgs": ["lsp"]
|
||||
}
|
||||
```
|
||||
|
||||
### Neovim (with nvim-lspconfig)
|
||||
|
||||
Add to your Neovim config (`init.lua`):
|
||||
|
||||
```lua
|
||||
local lspconfig = require('lspconfig')
|
||||
local configs = require('lspconfig.configs')
|
||||
|
||||
-- Register Lux as a new LSP
|
||||
if not configs.lux then
|
||||
configs.lux = {
|
||||
default_config = {
|
||||
cmd = { 'lux', 'lsp' },
|
||||
filetypes = { 'lux' },
|
||||
root_dir = function(fname)
|
||||
return lspconfig.util.find_git_ancestor(fname) or vim.fn.getcwd()
|
||||
end,
|
||||
settings = {},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
-- Enable the server
|
||||
lspconfig.lux.setup{}
|
||||
```
|
||||
|
||||
Also add filetype detection in `~/.config/nvim/ftdetect/lux.vim`:
|
||||
|
||||
```vim
|
||||
au BufRead,BufNewFile *.lux set filetype=lux
|
||||
```
|
||||
|
||||
### Neovim (with built-in LSP)
|
||||
|
||||
```lua
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'lux',
|
||||
callback = function()
|
||||
vim.lsp.start({
|
||||
name = 'lux',
|
||||
cmd = { 'lux', 'lsp' },
|
||||
root_dir = vim.fs.dirname(vim.fs.find({ '.git', 'lux.toml' }, { upward = true })[1]),
|
||||
})
|
||||
end,
|
||||
})
|
||||
```
|
||||
|
||||
### Emacs (with lsp-mode)
|
||||
|
||||
Add to your Emacs config:
|
||||
|
||||
```elisp
|
||||
(use-package lsp-mode
|
||||
:hook (lux-mode . lsp)
|
||||
:config
|
||||
(add-to-list 'lsp-language-id-configuration '(lux-mode . "lux"))
|
||||
(lsp-register-client
|
||||
(make-lsp-client
|
||||
:new-connection (lsp-stdio-connection '("lux" "lsp"))
|
||||
:major-modes '(lux-mode)
|
||||
:server-id 'lux-lsp)))
|
||||
```
|
||||
|
||||
### Emacs (with eglot)
|
||||
|
||||
```elisp
|
||||
(add-to-list 'eglot-server-programs '(lux-mode . ("lux" "lsp")))
|
||||
```
|
||||
|
||||
### Helix
|
||||
|
||||
Add to `~/.config/helix/languages.toml`:
|
||||
|
||||
```toml
|
||||
[[language]]
|
||||
name = "lux"
|
||||
scope = "source.lux"
|
||||
injection-regex = "lux"
|
||||
file-types = ["lux"]
|
||||
roots = ["lux.toml", ".git"]
|
||||
comment-token = "//"
|
||||
indent = { tab-width = 4, unit = " " }
|
||||
language-server = { command = "lux", args = ["lsp"] }
|
||||
```
|
||||
|
||||
### Sublime Text (with LSP package)
|
||||
|
||||
Add to `Preferences > Package Settings > LSP > Settings`:
|
||||
|
||||
```json
|
||||
{
|
||||
"clients": {
|
||||
"lux": {
|
||||
"enabled": true,
|
||||
"command": ["lux", "lsp"],
|
||||
"selector": "source.lux"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Zed
|
||||
|
||||
Add to your Zed settings:
|
||||
|
||||
```json
|
||||
{
|
||||
"lsp": {
|
||||
"lux": {
|
||||
"binary": {
|
||||
"path": "lux",
|
||||
"arguments": ["lsp"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Feature Details
|
||||
|
||||
### Diagnostics
|
||||
|
||||
The LSP server provides real-time diagnostics for:
|
||||
|
||||
- **Parse errors**: Syntax issues, missing tokens, unexpected input
|
||||
- **Type errors**: Type mismatches, missing fields, unknown identifiers
|
||||
- **Effect errors**: Missing effect declarations, unhandled effects
|
||||
- **Behavioral type errors**: Violations of `is pure`, `is total`, etc.
|
||||
|
||||
Diagnostics appear as you type, typically within 100ms of changes.
|
||||
|
||||
Example diagnostic:
|
||||
```
|
||||
error[E0308]: mismatched types
|
||||
--> src/main.lux:10:5
|
||||
|
|
||||
10 | return "hello"
|
||||
| ^^^^^^^ expected Int, found String
|
||||
```
|
||||
|
||||
### Hover Information
|
||||
|
||||
Hover over any symbol to see:
|
||||
|
||||
- **Functions**: Signature and documentation
|
||||
- **Types**: Type definition
|
||||
- **Keywords**: Syntax explanation
|
||||
- **Effects**: Effect operations
|
||||
|
||||
Example hover for `List.map`:
|
||||
```markdown
|
||||
```lux
|
||||
List.map(list: List<A>, f: A -> B): List<B>
|
||||
```
|
||||
|
||||
Transform each element in a list by applying a function.
|
||||
```
|
||||
|
||||
### Completions
|
||||
|
||||
The LSP provides context-aware completions:
|
||||
|
||||
#### Module Member Completions
|
||||
|
||||
After typing a module name and `.`, you get relevant members:
|
||||
|
||||
```lux
|
||||
List. // Shows: map, filter, fold, reverse, etc.
|
||||
String. // Shows: length, split, join, trim, etc.
|
||||
Console. // Shows: print, readLine, readInt
|
||||
```
|
||||
|
||||
#### Keyword Completions
|
||||
|
||||
At the start of statements:
|
||||
|
||||
```lux
|
||||
fn // Function declaration
|
||||
let // Variable binding
|
||||
type // Type declaration
|
||||
effect // Effect declaration
|
||||
match // Pattern matching
|
||||
```
|
||||
|
||||
#### Type Completions
|
||||
|
||||
In type position:
|
||||
|
||||
```lux
|
||||
Int, Float, Bool, String, Unit
|
||||
List, Option, Result
|
||||
```
|
||||
|
||||
### Go to Definition
|
||||
|
||||
Jump to the definition of:
|
||||
|
||||
- **Functions**: Goes to the `fn` declaration
|
||||
- **Types**: Goes to the `type` declaration
|
||||
- **Effects**: Goes to the `effect` declaration
|
||||
- **Let bindings**: Goes to the `let` statement
|
||||
- **Imports**: Goes to the imported module
|
||||
|
||||
Works with:
|
||||
- `Ctrl+Click` / `Cmd+Click` in most editors
|
||||
- `gd` in Vim/Neovim
|
||||
- `M-.` in Emacs
|
||||
|
||||
## Module Completions Reference
|
||||
|
||||
### List Module
|
||||
|
||||
| Method | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `length` | `(list: List<A>): Int` | Get list length |
|
||||
| `head` | `(list: List<A>): Option<A>` | First element |
|
||||
| `tail` | `(list: List<A>): List<A>` | All but first |
|
||||
| `map` | `(list: List<A>, f: A -> B): List<B>` | Transform elements |
|
||||
| `filter` | `(list: List<A>, p: A -> Bool): List<A>` | Keep matching |
|
||||
| `fold` | `(list: List<A>, init: B, f: (B, A) -> B): B` | Reduce |
|
||||
| `reverse` | `(list: List<A>): List<A>` | Reverse order |
|
||||
| `concat` | `(a: List<A>, b: List<A>): List<A>` | Join lists |
|
||||
| `range` | `(start: Int, end: Int): List<Int>` | Create range |
|
||||
| `get` | `(list: List<A>, index: Int): Option<A>` | Get at index |
|
||||
| `find` | `(list: List<A>, p: A -> Bool): Option<A>` | Find first match |
|
||||
| `isEmpty` | `(list: List<A>): Bool` | Check empty |
|
||||
| `take` | `(list: List<A>, n: Int): List<A>` | Take n elements |
|
||||
| `drop` | `(list: List<A>, n: Int): List<A>` | Drop n elements |
|
||||
| `any` | `(list: List<A>, p: A -> Bool): Bool` | Any matches |
|
||||
| `all` | `(list: List<A>, p: A -> Bool): Bool` | All match |
|
||||
|
||||
### String Module
|
||||
|
||||
| Method | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `length` | `(s: String): Int` | String length |
|
||||
| `split` | `(s: String, delim: String): List<String>` | Split by delimiter |
|
||||
| `join` | `(list: List<String>, delim: String): String` | Join with delimiter |
|
||||
| `trim` | `(s: String): String` | Remove whitespace |
|
||||
| `contains` | `(s: String, sub: String): Bool` | Check contains |
|
||||
| `replace` | `(s: String, from: String, to: String): String` | Replace |
|
||||
| `chars` | `(s: String): List<String>` | To char list |
|
||||
| `lines` | `(s: String): List<String>` | Split into lines |
|
||||
| `toUpper` | `(s: String): String` | Uppercase |
|
||||
| `toLower` | `(s: String): String` | Lowercase |
|
||||
|
||||
### Console Effect
|
||||
|
||||
| Operation | Signature | Description |
|
||||
|-----------|-----------|-------------|
|
||||
| `print` | `(msg: String): Unit` | Print message |
|
||||
| `readLine` | `(): String` | Read line |
|
||||
| `readInt` | `(): Int` | Read integer |
|
||||
|
||||
### Math Module
|
||||
|
||||
| Function | Signature | Description |
|
||||
|----------|-----------|-------------|
|
||||
| `abs` | `(x: Int): Int` | Absolute value |
|
||||
| `min` | `(a: Int, b: Int): Int` | Minimum |
|
||||
| `max` | `(a: Int, b: Int): Int` | Maximum |
|
||||
| `pow` | `(base: Float, exp: Float): Float` | Exponentiation |
|
||||
| `sqrt` | `(x: Float): Float` | Square root |
|
||||
| `floor` | `(x: Float): Int` | Floor |
|
||||
| `ceil` | `(x: Float): Int` | Ceiling |
|
||||
| `round` | `(x: Float): Int` | Round |
|
||||
|
||||
### File Effect
|
||||
|
||||
| Operation | Signature | Description |
|
||||
|-----------|-----------|-------------|
|
||||
| `read` | `(path: String): String` | Read file |
|
||||
| `write` | `(path: String, content: String): Unit` | Write file |
|
||||
| `exists` | `(path: String): Bool` | Check exists |
|
||||
| `delete` | `(path: String): Bool` | Delete file |
|
||||
| `listDir` | `(path: String): List<String>` | List directory |
|
||||
| `mkdir` | `(path: String): Bool` | Create directory |
|
||||
|
||||
### Http Effect
|
||||
|
||||
| Operation | Signature | Description |
|
||||
|-----------|-----------|-------------|
|
||||
| `get` | `(url: String): Result<String, String>` | HTTP GET |
|
||||
| `post` | `(url: String, body: String): Result<String, String>` | HTTP POST |
|
||||
| `put` | `(url: String, body: String): Result<String, String>` | HTTP PUT |
|
||||
| `delete` | `(url: String): Result<String, String>` | HTTP DELETE |
|
||||
|
||||
### Random Effect
|
||||
|
||||
| Operation | Signature | Description |
|
||||
|-----------|-----------|-------------|
|
||||
| `int` | `(min: Int, max: Int): Int` | Random integer |
|
||||
| `float` | `(): Float` | Random float 0-1 |
|
||||
| `bool` | `(): Bool` | Random boolean |
|
||||
|
||||
### Time Effect
|
||||
|
||||
| Operation | Signature | Description |
|
||||
|-----------|-----------|-------------|
|
||||
| `now` | `(): Int` | Current timestamp (ms) |
|
||||
| `sleep` | `(ms: Int): Unit` | Sleep for ms |
|
||||
|
||||
### Sql Effect
|
||||
|
||||
| Operation | Signature | Description |
|
||||
|-----------|-----------|-------------|
|
||||
| `connect` | `(url: String): Connection` | Connect to database |
|
||||
| `query` | `(conn: Connection, sql: String): List<Row>` | Execute query |
|
||||
| `execute` | `(conn: Connection, sql: String): Int` | Execute statement |
|
||||
| `transaction` | `(conn: Connection, f: () -> A): A` | Run in transaction |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### LSP Not Starting
|
||||
|
||||
1. Verify Lux is installed: `lux --version`
|
||||
2. Check the server starts: `lux lsp` (should wait for input)
|
||||
3. Check editor logs for connection errors
|
||||
|
||||
### No Completions
|
||||
|
||||
1. Ensure file has `.lux` extension
|
||||
2. Check file is valid (no parse errors)
|
||||
3. Verify LSP is connected (check status bar)
|
||||
|
||||
### Slow Diagnostics
|
||||
|
||||
The LSP re-parses and type-checks on every change. For large files:
|
||||
|
||||
1. Consider splitting into modules
|
||||
2. Check for complex recursive types
|
||||
3. Report performance issues on GitHub
|
||||
|
||||
### Debug Logging
|
||||
|
||||
Enable verbose logging:
|
||||
|
||||
```bash
|
||||
LUX_LSP_LOG=debug lux lsp
|
||||
```
|
||||
|
||||
Logs are written to stderr.
|
||||
|
||||
## Protocol Details
|
||||
|
||||
The Lux LSP server implements LSP version 3.17 with the following capabilities:
|
||||
|
||||
```json
|
||||
{
|
||||
"capabilities": {
|
||||
"textDocumentSync": "full",
|
||||
"hoverProvider": true,
|
||||
"completionProvider": {
|
||||
"triggerCharacters": ["."]
|
||||
},
|
||||
"definitionProvider": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Supported Methods
|
||||
|
||||
| Method | Support |
|
||||
|--------|---------|
|
||||
| `initialize` | Full |
|
||||
| `shutdown` | Full |
|
||||
| `textDocument/didOpen` | Full |
|
||||
| `textDocument/didChange` | Full |
|
||||
| `textDocument/didClose` | Full |
|
||||
| `textDocument/hover` | Full |
|
||||
| `textDocument/completion` | Full |
|
||||
| `textDocument/definition` | Full |
|
||||
| `textDocument/publishDiagnostics` | Full (server-initiated) |
|
||||
|
||||
## Contributing
|
||||
|
||||
The LSP implementation is in `src/lsp.rs`. To add new features:
|
||||
|
||||
1. Add capability to `ServerCapabilities`
|
||||
2. Implement handler in `handle_request`
|
||||
3. Add tests in `tests/lsp_tests.rs`
|
||||
4. Update this documentation
|
||||
|
||||
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup.
|
||||
@@ -150,6 +150,15 @@ Time.sleep(1000) // milliseconds
|
||||
let obj = Json.parse("{\"name\": \"Alice\"}")
|
||||
let str = Json.stringify(obj)
|
||||
|
||||
// SQL database effects
|
||||
let db = Sql.openMemory()
|
||||
Sql.execute(db, "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)")
|
||||
Sql.execute(db, "INSERT INTO users (name) VALUES ('Alice')")
|
||||
let users = Sql.query(db, "SELECT * FROM users")
|
||||
Sql.beginTx(db)
|
||||
Sql.commit(db) // or Sql.rollback(db)
|
||||
Sql.close(db)
|
||||
|
||||
// Module system
|
||||
import mymodule
|
||||
import utils/helpers as h
|
||||
@@ -179,10 +188,6 @@ fn processModern(x: Int @v2+): Int = x // v2 or later
|
||||
fn processAny(x: Int @latest): Int = x // any version
|
||||
```
|
||||
|
||||
### Planned (Not Yet Fully Implemented)
|
||||
|
||||
- **Auto-migration Generation**: Migration bodies stored, execution pending
|
||||
|
||||
---
|
||||
|
||||
## Primary Use Cases
|
||||
@@ -235,7 +240,7 @@ Quick iteration with type inference and a REPL.
|
||||
|------------|-------------|
|
||||
| **New Paradigm** | Effects require learning new concepts |
|
||||
| **Small Ecosystem** | Community packages just starting |
|
||||
| **No Package Registry** | Can share code via git/path, no central registry yet |
|
||||
| **Young Package Registry** | Package registry available, but small ecosystem |
|
||||
| **Early Stage** | Bugs likely, features incomplete |
|
||||
|
||||
---
|
||||
@@ -374,18 +379,10 @@ Values + Effects C Code → GCC/Clang
|
||||
- ✅ Formatter
|
||||
|
||||
**In Progress:**
|
||||
1. **Schema Evolution** - Type-declared migrations working, auto-generation pending
|
||||
2. **Error Message Quality** - Context lines shown, suggestions partial
|
||||
3. **Memory Management** - RC working for lists/boxed, closures/ADTs pending
|
||||
|
||||
**Recently Completed:**
|
||||
- ✅ **JavaScript Backend** - Full language support, browser & Node.js
|
||||
- ✅ **Dom Effect** - 40+ browser manipulation operations
|
||||
- ✅ **Html Module** - Type-safe HTML construction (Elm-style)
|
||||
- ✅ **TEA Runtime** - The Elm Architecture for web apps
|
||||
- ✅ **Package Manager** - `lux pkg` with git/path dependencies, module integration
|
||||
1. **Memory Management** - RC working for lists/boxed, closures/ADTs pending
|
||||
2. **Serialization Codecs** - JSON codec generation for versioned types
|
||||
|
||||
**Planned:**
|
||||
4. **SQL Effect** - Database access (as a package)
|
||||
5. **Package Registry** - Central repository for sharing packages
|
||||
6. **Behavioral Type Verification** - Total, idempotent, deterministic checking
|
||||
- **Connection Pooling** - Pool database connections
|
||||
- **WASM Backend** - WebAssembly compilation target
|
||||
- **Stream Processing** - Stream effect for data pipelines
|
||||
|
||||
@@ -153,27 +153,26 @@ A sequential guide to learning Lux, from basics to advanced topics.
|
||||
8. [Error Handling](guide/08-errors.md) - Fail effect, Option, Result
|
||||
9. [Standard Library](guide/09-stdlib.md) - Built-in functions
|
||||
10. [Advanced Topics](guide/10-advanced.md) - Traits, generics, optimization
|
||||
11. [Databases](guide/11-databases.md) - SQL, transactions, testing with handlers
|
||||
|
||||
### [Language Reference](reference/syntax.md)
|
||||
Complete syntax and semantics reference.
|
||||
|
||||
- [Syntax](reference/syntax.md) - Grammar and syntax rules
|
||||
- [Types](reference/types.md) - Type system details
|
||||
- [Effects](reference/effects.md) - Effect system reference
|
||||
- [Standard Library](reference/stdlib.md) - All built-in functions
|
||||
- [Standard Library](guide/09-stdlib.md) - Built-in functions and modules
|
||||
|
||||
### [Tutorials](tutorials/README.md)
|
||||
Project-based learning.
|
||||
|
||||
**Standard Programs:**
|
||||
- [Calculator](tutorials/calculator.md) - Basic REPL calculator
|
||||
- [Todo App](tutorials/todo.md) - File I/O and data structures
|
||||
- [HTTP Client](tutorials/http-client.md) - Fetching web data
|
||||
|
||||
**Effect Showcases:**
|
||||
- [Dependency Injection](tutorials/dependency-injection.md) - Testing with effects
|
||||
- [State Machines](tutorials/state-machines.md) - Modeling state with effects
|
||||
- [Parser Combinators](tutorials/parsers.md) - Effects for backtracking
|
||||
- [Project Ideas](tutorials/project-ideas.md) - Ideas for building with Lux
|
||||
|
||||
### Design Documents
|
||||
- [Packages](PACKAGES.md) - Package manager and dependencies
|
||||
- [SQL Design Analysis](SQL_DESIGN_ANALYSIS.md) - SQL as built-in vs package
|
||||
- [Roadmap](ROADMAP.md) - Development priorities and status
|
||||
- [Website Plan](WEBSITE_PLAN.md) - Website architecture and content
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
| Runtime versioned values | ✅ Complete |
|
||||
| Schema registry & compatibility checking | ✅ Complete |
|
||||
| Basic migration execution | ✅ Complete |
|
||||
| Type system integration | ⚠️ Partial (versions ignored in typechecker) |
|
||||
| Auto-migration generation | ❌ Missing |
|
||||
| Type system integration | ✅ Complete |
|
||||
| Auto-migration generation | ✅ Complete |
|
||||
| Serialization/codec support | ❌ Missing |
|
||||
|
||||
### Behavioral Types
|
||||
@@ -24,10 +24,11 @@
|
||||
| Parser (`is pure`, `is total`, etc.) | ✅ Complete |
|
||||
| AST & PropertySet | ✅ Complete |
|
||||
| Pure function checking (no effects) | ✅ Complete |
|
||||
| Total verification | ❌ Missing |
|
||||
| Idempotent verification | ❌ Missing |
|
||||
| Deterministic verification | ❌ Missing |
|
||||
| Where clause enforcement | ❌ Missing |
|
||||
| Total verification (no Fail, structural recursion) | ✅ Complete |
|
||||
| Idempotent verification (pattern-based) | ✅ Complete |
|
||||
| Deterministic verification (no Random/Time) | ✅ Complete |
|
||||
| Commutative verification (2 params, commutative op) | ✅ Complete |
|
||||
| Where clause property constraints | ✅ Complete |
|
||||
|
||||
---
|
||||
|
||||
@@ -49,9 +50,9 @@
|
||||
|
||||
| Task | Priority | Effort | Status |
|
||||
|------|----------|--------|--------|
|
||||
| SQL effect (query, execute) | P1 | 2 weeks | ❌ Missing |
|
||||
| SQL effect (query, execute) | P1 | 2 weeks | ✅ Complete |
|
||||
| Transaction effect | P2 | 1 week | ✅ Complete |
|
||||
| Connection pooling | P2 | 1 week | ❌ Missing |
|
||||
| Transaction effect | P2 | 1 week | ❌ Missing |
|
||||
|
||||
### Phase 1.3: Web Server Framework
|
||||
|
||||
@@ -66,7 +67,7 @@
|
||||
|
||||
| Task | Priority | Effort | Status |
|
||||
|------|----------|--------|--------|
|
||||
| Elm-quality error messages | P1 | 2 weeks | ⚠️ Partial (context shown, suggestions missing) |
|
||||
| Elm-quality error messages | P1 | 2 weeks | ✅ Complete (field suggestions, error categories) |
|
||||
| Full JS compilation | P2 | 4 weeks | ✅ Complete |
|
||||
| Hot reload / watch mode | P2 | — | ✅ Complete |
|
||||
| Debugger improvements | P3 | 2 weeks | ✅ Basic |
|
||||
@@ -88,15 +89,16 @@
|
||||
|
||||
| Task | Priority | Effort | Status |
|
||||
|------|----------|--------|--------|
|
||||
| Total function verification | P1 | 2 weeks | ❌ Missing |
|
||||
| Idempotent verification | P1 | 2 weeks | ❌ Missing |
|
||||
| Deterministic verification | P1 | 1 week | ❌ Missing |
|
||||
| Where clause enforcement | P1 | 1 week | ❌ Missing |
|
||||
| Total function verification | P1 | 2 weeks | ✅ Complete |
|
||||
| Idempotent verification | P1 | 2 weeks | ✅ Complete |
|
||||
| Deterministic verification | P1 | 1 week | ✅ Complete |
|
||||
| Where clause enforcement | P1 | 1 week | ✅ Complete |
|
||||
|
||||
**Implementation approach:**
|
||||
- **Total:** Restrict to structural recursion, require termination proof for general recursion
|
||||
- **Idempotent:** Pattern-based (setter patterns, specific effect combinations)
|
||||
- **Deterministic:** Effect analysis (no Random, Time, or non-deterministic IO)
|
||||
**Implementation approach (completed):**
|
||||
- **Total:** Checks for no Fail effect + structural recursion for termination
|
||||
- **Idempotent:** Pattern-based recognition (constants, identity, clamping, abs, projections)
|
||||
- **Deterministic:** Effect analysis (no Random or Time effects)
|
||||
- **Commutative:** Requires 2 params with commutative operation (+, *, min, max, etc.)
|
||||
|
||||
### Phase 2.2: Refinement Types (Stretch Goal)
|
||||
|
||||
@@ -130,10 +132,10 @@
|
||||
|
||||
| Task | Priority | Effort | Status |
|
||||
|------|----------|--------|--------|
|
||||
| Type system version tracking | P1 | 1 week | ⚠️ Partial |
|
||||
| Auto-migration generation | P1 | 2 weeks | ❌ Missing |
|
||||
| Version compatibility errors | P1 | 1 week | ❌ Missing |
|
||||
| Migration chain optimization | P2 | 1 week | ⚠️ Basic |
|
||||
| Type system version tracking | P1 | 1 week | ✅ Complete |
|
||||
| Auto-migration generation | P1 | 2 weeks | ✅ Complete |
|
||||
| Version compatibility errors | P1 | 1 week | ✅ Complete |
|
||||
| Migration chain optimization | P2 | 1 week | ✅ Complete |
|
||||
|
||||
### Phase 3.2: Serialization Support
|
||||
|
||||
@@ -205,7 +207,7 @@
|
||||
|------|----------|--------|--------|
|
||||
| Package manager (lux pkg) | P1 | 3 weeks | ✅ Complete |
|
||||
| Module loader integration | P1 | 1 week | ✅ Complete |
|
||||
| Package registry | P2 | 2 weeks | ❌ Missing |
|
||||
| Package registry | P2 | 2 weeks | ✅ Complete (server + CLI commands) |
|
||||
| Dependency resolution | P2 | 2 weeks | ❌ Missing |
|
||||
|
||||
**Package Manager Features:**
|
||||
@@ -219,8 +221,8 @@
|
||||
|
||||
| Task | Priority | Effort | Status |
|
||||
|------|----------|--------|--------|
|
||||
| LSP completions | P1 | 1 week | ⚠️ Basic |
|
||||
| LSP go-to-definition | P1 | 1 week | ⚠️ Partial |
|
||||
| LSP completions | P1 | 1 week | ✅ Complete (module-specific completions) |
|
||||
| LSP go-to-definition | P1 | 1 week | ✅ Complete (functions, lets, types) |
|
||||
| Formatter | P2 | — | ✅ Complete |
|
||||
| Documentation generator | P2 | 1 week | ❌ Missing |
|
||||
|
||||
@@ -253,21 +255,21 @@
|
||||
3. ~~**File effect**~~ ✅ Done
|
||||
4. ~~**HTTP client effect**~~ ✅ Done
|
||||
5. ~~**JSON support**~~ ✅ Done
|
||||
6. **Elm-quality errors** — ⚠️ In progress
|
||||
6. ~~**Elm-quality errors**~~ ✅ Done
|
||||
|
||||
### Quarter 2: Backend Services (Use Case 1)
|
||||
### Quarter 2: Backend Services (Use Case 1) ✅ COMPLETE
|
||||
|
||||
7. **HTTP server effect** — Build APIs
|
||||
8. **SQL effect** — Database access
|
||||
9. **Full JS compilation** — Deployment
|
||||
10. **Package manager** — Code sharing
|
||||
7. ~~**HTTP server effect**~~ ✅ Done
|
||||
8. ~~**SQL effect**~~ ✅ Done
|
||||
9. ~~**Full JS compilation**~~ ✅ Done
|
||||
10. ~~**Package manager**~~ ✅ Done
|
||||
|
||||
### Quarter 3: Reliability (Use Case 2)
|
||||
### Quarter 3: Reliability (Use Case 2) ✅ COMPLETE
|
||||
|
||||
11. **Behavioral type verification** — Total, idempotent, deterministic
|
||||
12. **Where clause enforcement** — Type-level guarantees
|
||||
13. **Schema evolution completion** — Version tracking in types
|
||||
14. **Auto-migration generation** — Reduce boilerplate
|
||||
11. ~~**Behavioral type verification**~~ ✅ Done
|
||||
12. ~~**Where clause enforcement**~~ ✅ Done
|
||||
13. ~~**Schema evolution completion**~~ ✅ Done
|
||||
14. ~~**Auto-migration generation**~~ ✅ Done
|
||||
|
||||
### Quarter 4: Polish (Use Cases 3 & 4)
|
||||
|
||||
@@ -322,9 +324,9 @@
|
||||
- ✅ Watch mode
|
||||
- ✅ Debugger (basic)
|
||||
|
||||
**Advanced (Parsing Only):**
|
||||
- ✅ Schema evolution (parsing, runtime values)
|
||||
- ✅ Behavioral types (parsing, pure checking only)
|
||||
**Advanced:**
|
||||
- ✅ Schema evolution (parser, runtime, migrations, compatibility checking)
|
||||
- ✅ Behavioral types (pure, total, idempotent, deterministic, commutative verification)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user