Skip to content

Commit 9645feb

Browse files
authored
docs: clarify release example contract (#18)
1 parent e103826 commit 9645feb

3 files changed

Lines changed: 41 additions & 13 deletions

File tree

.github/workflows/ci-tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ jobs:
5454
- name: Check Spore files
5555
run: |
5656
find src/basic_cli -name '*.sp' -type f | sort | xargs -n 1 spore check
57+
spore check examples/hello.sp
5758
spore check examples/hello-app/src/main.sp
5859
59-
- name: Build Spore files
60+
- name: Build Spore platform API files
6061
run: |
6162
find src/basic_cli -name '*.sp' -type f | sort | xargs -n 1 spore build
62-
spore build examples/hello-app/src/main.sp
6363
64-
- name: Run project-mode hello-app example
64+
- name: Run Spore examples
6565
run: |
66+
spore run examples/hello.sp
6667
(
6768
cd examples/hello-app
6869
echo "✓ Running project-mode example (default entry)"

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ basic-cli = { path = "../.." }
5555
import basic_cli.stdout as stdout
5656
5757
fn main() -> () uses [Console] {
58-
println("Hello from a project-mode Spore application!")
58+
println("Hello from a project-mode Spore application!");
5959
return
6060
}
6161
```
@@ -67,9 +67,9 @@ spore check src/main.sp
6767
spore run src/main.sp
6868
```
6969

70-
This is a real package-backed application. The in-repo example points `basic-cli` at `../..`; projects generated by `spore new` vendor the package and use `vendor/basic-cli` instead. The formatter currently normalizes the import to `import basic_cli.stdout as stdout`, while `println` still resolves directly in scope.
70+
This is a real package-backed application. The in-repo example points `basic-cli` at `../..`; projects generated by `spore new` vendor the package and use `vendor/basic-cli` instead. The formatter currently normalizes the import to `import basic_cli.stdout as stdout`, while `println` still resolves directly in scope as an imported platform API call.
7171

72-
For quick experiments, you can also run standalone `.sp` files (see `examples/hello.sp`), but production applications should use the project-mode structure above.
72+
For quick experiments, you can also run pure standalone `.sp` files (see `examples/hello.sp`), but production applications that call platform APIs such as `println` should use the project-mode structure above.
7373

7474
## Project Structure
7575

@@ -90,7 +90,7 @@ basic-cli/
9090
│ ├── Cargo.toml
9191
│ └── src/
9292
│ └── lib.rs # Foreign function implementations
93-
└── examples/ # Canonical examples that format/check/build in CI
93+
└── examples/ # Canonical examples that format/check/run in CI
9494
```
9595

9696
## Contract Surface (MVP)
@@ -108,18 +108,35 @@ Applications targeting `basic-cli` must implement the same startup function name
108108

109109
## Tutorial Contract
110110

111-
- `examples/hello-app/` is the **canonical project-mode example** — it is formatted, checked, built, and run in CI.
112-
- `examples/hello.sp` is a minimal standalone file for quick experiments.
111+
- `examples/hello-app/` is the **canonical project-mode example** — it is formatted, checked, and run in CI.
112+
- `examples/hello.sp` is a minimal pure standalone file for quick experiments — it is formatted, checked, and run in CI.
113113
- `src/basic_cli/` is the API surface for the platform modules themselves.
114114
- `src/platform_contract.sp` is the package-owned startup contract surface.
115115
- Only add `tests/` when the repo has real Spore-side regression coverage worth running with `spore test`.
116116

117117
If you want to add a new tutorial/example, treat this as the bar:
118118

119119
1. keep it self-contained;
120-
2. make sure it passes `spore format --check`, `spore check`, and `spore build`;
120+
2. make sure it passes `spore format --check`, `spore check`, and `spore run`;
121121
3. only then promote it into `examples/` and mention it in this README.
122122

123+
Native `spore build` is still useful for platform API modules and pure standalone files, but it is not required for package-backed platform projects that rely on `foreign fn` declarations until the backend supports foreign/platform lowering.
124+
125+
## Platform API Calls and Effect Syntax
126+
127+
Project-mode applications call imported `basic-cli` platform functions directly:
128+
129+
```spore
130+
import basic_cli.stdout as stdout
131+
132+
fn main() -> () uses [Console] {
133+
println("Hello from basic-cli!");
134+
return
135+
}
136+
```
137+
138+
In this style, the `uses [Console]` clause records the capability required by the direct `println` platform API call. The lower-level `perform Effect.op(...)` form belongs to effect-handler syntax; use it only when documenting or implementing explicit handlers, not for the normal `basic-cli` project-mode tutorial path.
139+
123140
## Design Philosophy
124141

125142
Following Spore's [SEP-0003 (Effect System)](https://github.com/spore-lang/spore-evolution/blob/main/seps/SEP-0003-effect-system.md):
@@ -135,7 +152,7 @@ Following Spore's [SEP-0003 (Effect System)](https://github.com/spore-lang/spore
135152

136153
The canonical example is the **package-backed project-mode** `examples/hello-app/` application. It already validates and runs with `[project].platform = "basic-cli"`, an in-repo path dependency, and `import basic_cli.stdout`.
137154

138-
The standalone file example (`examples/hello.sp`) stays around for quick experiments. The main remaining platform gaps are generic handled-effects enforcement, startup `spec` stacking, and lifting the runtime from its current explicit `basic-cli` host profile to a more general package-backed mechanism.
155+
The pure standalone file example (`examples/hello.sp`) stays around for quick experiments. The main remaining platform gaps are generic handled-effects enforcement, startup `spec` stacking, native lowering for `foreign fn` platform projects, and lifting the runtime from its current explicit `basic-cli` host profile to a more general package-backed mechanism.
139156

140157
## License
141158

examples/hello.sp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
/// A simple "Hello World" using the basic-cli platform.
1+
/// A minimal pure standalone Spore file.
22
///
33
/// Run with: spore run examples/hello.sp
4-
fn main() -> () uses [Console] { println("Hello from Spore basic-cli!") }
4+
///
5+
/// This intentionally does not import or call the basic-cli platform. Platform
6+
/// APIs such as `println` are available from package-backed applications like
7+
/// `examples/hello-app/`, not from standalone files.
8+
fn greeting(name: Str) -> Str { "Hello, " + name + "!" }
9+
10+
fn main() -> () {
11+
let message = greeting("standalone Spore");
12+
message;
13+
return
14+
}

0 commit comments

Comments
 (0)