feat: add Random, Time, and File effects to C backend
New effects with evidence passing support: Random effect: - int(min, max) - random integer in range - float() - random float 0-1 - bool() - random boolean Time effect: - now() - milliseconds since epoch - sleep(ms) - pause execution File effect: - read(path) - read file contents - write(path, content) - write file - append(path, content) - append to file - exists(path) - check if file exists - delete(path) - delete file - isDir(path) - check if directory - mkdir(path) - create directory Also fixed: - Function calls as statements now properly emit in generated C - Return type inference for all effect operations Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -275,7 +275,7 @@ See [docs/EVIDENCE_PASSING.md](EVIDENCE_PASSING.md) for details.
|
||||
|
||||
## Future Roadmap
|
||||
|
||||
### Phase 2: Perceus Reference Counting
|
||||
### Phase 4: Perceus Reference Counting
|
||||
|
||||
**Goal:** Deterministic memory management without GC pauses.
|
||||
|
||||
@@ -292,15 +292,22 @@ fn increment(xs: List<Int>): List<Int> =
|
||||
|
||||
If `xs` has refcount=1, the list can be mutated in-place instead of copied.
|
||||
|
||||
### Phase 3: More Effects
|
||||
### Phase 2: More Effects ✅ COMPLETE
|
||||
|
||||
Implement C versions of:
|
||||
- `File` (read, write, exists)
|
||||
- `Http` (get, post)
|
||||
- `Random` (int, bool)
|
||||
- `Time` (now, sleep)
|
||||
Implemented C versions of:
|
||||
- `Random` (int, float, bool) - LCG random number generator
|
||||
- `Time` (now, sleep) - using clock_gettime/nanosleep
|
||||
- `File` (read, write, append, exists, delete, isDir, mkdir)
|
||||
|
||||
### Phase 4: JavaScript Backend
|
||||
All effects use evidence passing for handler customization.
|
||||
|
||||
### Phase 3: Http Effect
|
||||
|
||||
Implement HTTP client:
|
||||
- `Http.get(url)` - GET request
|
||||
- `Http.post(url, body)` - POST request
|
||||
|
||||
### Phase 5: JavaScript Backend
|
||||
|
||||
Compile Lux to JavaScript for browser/Node.js:
|
||||
- Effects → Direct DOM/API calls
|
||||
|
||||
Reference in New Issue
Block a user