Skip to content

Commit d770885

Browse files
brielovclaude
andcommitted
Update README with multi-target support and main function requirement
- Document multi-target compilation (node, deno, browser, cloudflare) - Add compilation targets table with feature availability - Update Quick Start with run command and target examples - Add main function requirement to syntax overview - Document File, Dir, Path modules 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 89129e0 commit d770885

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

README.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ A small, experimental programming language with Hindley-Milner type inference th
2828

2929
### Compiler
3030

31-
- Compiles to JavaScript
31+
- Compiles to JavaScript with **multi-target support**: Node.js, Deno, Browser, Cloudflare Workers
3232
- A-Normal Form intermediate representation
3333
- Basic optimizations (constant folding, dead code elimination)
3434
- Comprehensive standard library (prelude)
35+
- Required `main : List String -> a` entry point with command-line arguments
3536

3637
## Quick Start
3738

@@ -42,19 +43,27 @@ bun install
4243
# Type check a file
4344
bun run src/index.ts check examples/basics/main.alg
4445

45-
# Compile and run
46-
bun run src/index.ts compile examples/basics/main.alg | bun run -
46+
# Compile and run (with arguments)
47+
bun run src/index.ts run examples/basics/main.alg -- arg1 arg2
4748

48-
# Or use the shorthand
49-
bun run src/index.ts -t file.alg # type check
50-
bun run src/index.ts -c file.alg # compile
49+
# Compile to JavaScript
50+
bun run src/index.ts compile examples/basics/main.alg > out.js
51+
52+
# Compile for different targets
53+
bun run src/index.ts compile --target deno file.alg # Deno
54+
bun run src/index.ts compile --target browser file.alg # Browser
55+
bun run src/index.ts compile --target cloudflare file.alg # Cloudflare Workers
5156
```
5257

5358
## Syntax Overview
5459

5560
```
5661
-- Line comments start with --
5762
63+
-- Every program needs a main function
64+
let main = args ->
65+
IO.printLine "Hello, World!"
66+
5867
-- Type declarations
5968
type Maybe a = Nothing | Just a
6069
type List a = Nil | Cons a (List a)
@@ -132,7 +141,29 @@ The prelude provides common types and functions:
132141

133142
**List**: `map`, `filter`, `foldl`, `foldr`, `length`, `reverse`, `append`, `concat`, `head`, `tail`, `take`, `drop`, `zip`, `any`, `all`, `find`, `elem`, `nub`, `sortBy`
134143

135-
**Foreign modules**: `String`, `Char`, `Int`, `Float`, `IO`, `Debug`, `Map`, `Set`
144+
**Foreign modules**: `String`, `Char`, `Int`, `Float`, `IO`, `Debug`, `Map`, `Set`, `File`, `Dir`, `Path`
145+
146+
Note: `File` and `Dir` modules are only available on Node.js and Deno targets.
147+
148+
## Compilation Targets
149+
150+
Algow supports multiple JavaScript runtimes:
151+
152+
| Target | Description | File/Dir Access |
153+
|--------|-------------|-----------------|
154+
| `node` (default) | Node.js / Bun | Yes |
155+
| `deno` | Deno runtime | Yes |
156+
| `browser` | Web browsers | No |
157+
| `cloudflare` | Cloudflare Workers | No |
158+
159+
```bash
160+
# Compile for Deno
161+
bun run src/index.ts compile --target deno app.alg > app.js
162+
deno run --allow-read app.js
163+
164+
# Compile for browser (outputs ES module)
165+
bun run src/index.ts compile --target browser app.alg > app.js
166+
```
136167

137168
## Examples
138169

0 commit comments

Comments
 (0)