-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgetting-started.html
More file actions
442 lines (416 loc) · 19.3 KB
/
Copy pathgetting-started.html
File metadata and controls
442 lines (416 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Getting started — IronKernel</title>
<meta
name="description"
content="Install IronKernel binaries, use the ik tool, run your first program, and connect the VS Code extension."
/>
<link rel="icon" href="../assets/ironkernel-mark.png" type="image/png" />
<link rel="stylesheet" href="../assets/site.css" />
</head>
<body>
<header class="nav">
<div class="wrap nav-inner">
<a class="brand" href="../index.html">
<img src="../assets/ironkernel-mark.png" alt="" width="32" height="32" />
IronKernel
</a>
<ul class="nav-links">
<li><a href="getting-started.html" aria-current="page">Start</a></li>
<li><a href="intro.html">Intro</a></li>
<li><a href="guide.html">Guide</a></li>
<li><a href="operators.html">Operators</a></li>
<li><a href="https://github.com/ironkernel-lang/IronKernel">GitHub</a></li>
</ul>
</div>
</header>
<div class="wrap docs-shell">
<aside class="docs-side">
<h2>Docs</h2>
<ol>
<li><a href="getting-started.html" aria-current="page">Getting started</a></li>
<li><a href="intro.html">Introduction</a></li>
<li><a href="guide.html">Language guide</a></li>
<li><a href="operators.html">Operators</a></li>
</ol>
<h2 style="margin-top: 1.5rem">On this page</h2>
<ol>
<li><a href="#install">Install (<code>ik</code> / binary)</a></li>
<li><a href="#verify">Verify</a></li>
<li><a href="#first-run">REPL</a></li>
<li><a href="#scripts">Scripts & args</a></li>
<li><a href="#packages">IKC packages</a></li>
<li><a href="#projects">Projects (<code>ik</code>)</a></li>
<li><a href="#editor">VS Code</a></li>
<li><a href="#errors">Errors</a></li>
<li><a href="#capabilities">Capabilities</a></li>
<li><a href="#effects">Effects & async</a></li>
<li><a href="#contracts">Contracts</a></li>
<li><a href="#from-source">From source</a></li>
<li><a href="#next">Next steps</a></li>
</ol>
</aside>
<article class="docs-main">
<h1>Getting started</h1>
<p class="lede">
Install a release binary (or the <code>ik</code> .NET tool), put it on your
<code>PATH</code>, then run the REPL, scripts, and projects. You do
<strong>not</strong> need to clone the repository or prefix commands with
<code>dotnet run --project IronKernel</code> for day-to-day use.
</p>
<h2 id="install">1. Install</h2>
<p>
Prefer the NuGet global tool (<code>ik</code>) when you already have the
.NET 10 SDK. Use a self-contained release binary when you want a single
executable with no SDK. Both expose the same CLI; only the command name differs.
</p>
<h3 id="install-tool">Option A — <code>ik</code> from NuGet.org (recommended)</h3>
<p>
<a href="https://www.nuget.org/packages/IronKernel.Tool"><code>IronKernel.Tool</code></a>
is a .NET global tool with command name <code>ik</code>.
<a href="https://www.nuget.org/packages/IronKernel.Sdk"><code>IronKernel.Sdk</code></a>
is the MSBuild SDK used by <code>.ikproj</code> files
(<code><Project Sdk="IronKernel.Sdk/…"></code>); restore pulls it automatically
when a project references it.
</p>
<p>
<strong>Requires the .NET 10 SDK.</strong> Check with
<code>dotnet --list-sdks</code> — you need a <code>10.0.x</code> line.
Install from
<a href="https://dotnet.microsoft.com/download">dotnet.microsoft.com/download</a>
if needed.
</p>
<div class="example">
<p class="example-caption">Install the global tool</p>
<pre><code class="language-shell">dotnet tool install -g IronKernel.Tool
# Ensure global tools are on PATH (often already set by the SDK installer):
export PATH="$PATH:$HOME/.dotnet/tools"
ik --version</code></pre>
</div>
<p>Upgrade later with:</p>
<div class="example">
<pre><code class="language-shell">dotnet tool update -g IronKernel.Tool</code></pre>
</div>
<p>
The tool stores <code>kernel.ikr</code> / <code>promises.ikr</code> next to its
assembly under the .NET tool store, so you do not keep a separate stdlib folder.
</p>
<p>
If install fails with
<em>Settings file 'DotnetToolSettings.xml' was not found in the package</em>,
the package itself is fine — that message is a known .NET SDK quirk when the
active SDK is older than the tool’s target framework (<code>net10.0</code>).
Install or select a .NET 10 SDK, then retry. Confirm with
<code>dotnet --version</code> (should report 10.x) and that no older
<code>global.json</code> in the current directory is pinning an earlier SDK.
</p>
<h3 id="install-binary">Option B — Release binary (no SDK required)</h3>
<p>
<a href="https://github.com/ironkernel-lang/IronKernel/releases">GitHub Releases</a>
ship self-contained archives named <code>ironkernel-<rid>.tar.gz</code>.
Choose the RID for your machine:
</p>
<ul>
<li><code>linux-x64</code> — Linux x86_64</li>
<li><code>win-x64</code> — Windows x64</li>
<li><code>osx-arm64</code> — macOS Apple Silicon</li>
<li><code>osx-x64</code> — macOS Intel</li>
</ul>
<p>
Inside the archive you get <code>IronKernel</code> (or
<code>IronKernel.exe</code> on Windows), plus <code>kernel.ikr</code> and
<code>promises.ikr</code>. Those three files must stay in the same directory —
the runtime loads the standard library from beside the executable.
</p>
<div class="example">
<p class="example-caption">macOS Apple Silicon · example for v0.3.1</p>
<pre><code class="language-shell">curl -L -o ironkernel.tar.gz \
https://github.com/ironkernel-lang/IronKernel/releases/download/v0.3.1/ironkernel-osx-arm64.tar.gz
tar -xzf ironkernel.tar.gz
mkdir -p "$HOME/.local/opt"
mv ironkernel-osx-arm64 "$HOME/.local/opt/ironkernel"
export PATH="$HOME/.local/opt/ironkernel:$PATH"
# Add the export to ~/.zshrc or ~/.bashrc so it persists.</code></pre>
</div>
<div class="example">
<p class="example-caption">Linux x64 · same idea</p>
<pre><code class="language-shell">curl -L -o ironkernel.tar.gz \
https://github.com/ironkernel-lang/IronKernel/releases/download/v0.3.1/ironkernel-linux-x64.tar.gz
tar -xzf ironkernel.tar.gz
mkdir -p "$HOME/.local/opt"
mv ironkernel-linux-x64 "$HOME/.local/opt/ironkernel"
export PATH="$HOME/.local/opt/ironkernel:$PATH"</code></pre>
</div>
<div class="example">
<p class="example-caption">Windows x64 (PowerShell)</p>
<pre><code class="language-shell"># Download ironkernel-win-x64.tar.gz from the releases page, then:
tar -xzf ironkernel-win-x64.tar.gz
# Move the folder somewhere stable, e.g. %LOCALAPPDATA%\IronKernel
# Add that folder to your user PATH. The command name is IronKernel.exe.</code></pre>
</div>
<p>
After <code>PATH</code> is set, the command is <code>IronKernel</code>
(<code>IronKernel.exe</code> on Windows).
</p>
<h3 id="which-command">Which command do I type?</h3>
<ul>
<li>Global tool (Option A) → <code>ik</code></li>
<li>Release archive on <code>PATH</code> (Option B) → <code>IronKernel</code></li>
</ul>
<p>
They accept the same arguments. The rest of this page shows <code>ik</code>;
if you installed Option B, substitute <code>IronKernel</code> everywhere
(for example <code>IronKernel run hello.ikr</code>).
</p>
<h2 id="verify">2. Verify the install</h2>
<div class="example">
<pre><code class="language-shell">ik --version
# or: IronKernel --version</code></pre>
</div>
<p>
You should see a version string such as <code>0.3.1-net10</code>. If the shell
says “command not found”, your <code>PATH</code> does not include the install
directory (or <code>~/.dotnet/tools</code> for the global tool).
</p>
<h2 id="first-run">3. Start the REPL</h2>
<div class="example">
<pre><code class="language-shell">ik
# or: IronKernel</code></pre>
</div>
<p>
Enter <code>(+ 20 22)</code> and type <code>quit</code> to leave. The interactive
line editor needs a real terminal; use script mode in automation and CI.
</p>
<h2 id="scripts">4. Run a script</h2>
<p>Create a file and pass it to the CLI (no repository clone required):</p>
<div class="example">
<pre><code class="language-shell">cat > hello.ikr <<'EOF'
(define write
(lambda (x) (. System.Console WriteLine x)))
(write "Hello,world!")
EOF
ik hello.ikr
# Explicit form (same thing):
ik run hello.ikr one two</code></pre>
<div class="example-out">Hello,world!</div>
</div>
<p>
Extra arguments after the script path are available as the Kernel list
<code>args</code>. Script paths resolve from your current directory; the
standard library is loaded from beside the installed runtime.
</p>
<h2 id="packages">5. Compile and run an IKC package</h2>
<div class="example">
<pre><code class="language-shell">ik compile hello.ikr -o hello.ikc
ik run hello.ikc</code></pre>
</div>
<p>
An <code>.ikc</code> file is an IronKernel source package, not a CLR assembly.
Packaging validates and compiles without executing; execution happens only when
you run the package.
</p>
<h2 id="projects">6. Create a project with <code>ik</code></h2>
<p>
<code>.ikproj</code> projects are managed by the same CLI. Prefer the
<code>ik</code> tool name in docs and scripts; with a release binary the
equivalent is <code>IronKernel new …</code>, <code>IronKernel run</code>, and so on.
</p>
<div class="example">
<pre><code class="language-shell">ik new app hello
cd hello
ik run
ik test
ik add Acme.IronKernel.Http 1.2.0
ik add Npgsql 9.0.0 --clr
ik restore
ik tree
ik build
ik pack</code></pre>
</div>
<p>
Projects reuse NuGet for IronKernel source packages and CLR libraries.
Load order is stdlib → restored packages → project sources (sorted) →
<code>IronKernelMain</code> last. Commit <code>packages.lock.json</code> and use
<code>ik restore --locked</code> in CI.
</p>
<p>
For a multi-file HTTP example from the repository, see
<a href="https://github.com/ironkernel-lang/IronKernel/tree/master/Examples/lantern"><code>Examples/lantern/</code></a>
(<code>ik run</code> from that directory, or
<code>ik run path/to/lantern.ikproj</code>).
</p>
<h2 id="editor">7. VS Code extension</h2>
<p>
The extension provides syntax highlighting (operatives vs applicatives), snippets,
diagnostics, Run/Build commands, and a playground backed by the real CLI — not a
second evaluator in JavaScript.
</p>
<h3>Install the extension</h3>
<p>
The extension is not on the Marketplace yet. Build a VSIX from the repository
(or grab the <code>ironkernel-vscode</code> artifact from the
<a href="https://github.com/ironkernel-lang/IronKernel/actions/workflows/vscode-extension.yml">VS Code extension</a>
GitHub Actions workflow), then install it in VS Code:
</p>
<div class="example">
<pre><code class="language-shell">git clone https://github.com/ironkernel-lang/IronKernel
cd IronKernel/editors/vscode
npm install
npm run package
# In VS Code: Extensions → ⋯ → Install from VSIX… → select the .vsix</code></pre>
</div>
<h3>How the extension finds IronKernel</h3>
<p>
Run, Compile, Run Project, Build Project, and the playground all shell out to the
real runtime. Resolution order:
</p>
<ol>
<li>
<strong><code>ironkernel.executablePath</code></strong> — if set, must be an
<em>absolute</em> path to the <code>IronKernel</code> binary or the <code>ik</code>
shim (for example <code>/Users/you/.local/opt/ironkernel/IronKernel</code> or
<code>/Users/you/.dotnet/tools/ik</code>). The extension runs that file directly
and uses its directory as the working directory so adjacent
<code>kernel.ikr</code> / <code>promises.ikr</code> resolve for release installs.
</li>
<li>
<strong>Workspace .NET project</strong> — if the open workspace contains
<code>IronKernel/IronKernel.fsproj</code> (override with
<code>ironkernel.projectPath</code>), the extension uses
<code>dotnet run --project … --</code>. This is for people developing IronKernel
itself, not for app authors.
</li>
<li>
<strong><code>PATH</code></strong> — otherwise it invokes
<code>IronKernel</code> (<code>IronKernel.exe</code> on Windows). Putting the
release directory on your <code>PATH</code> (Option A) is enough for this step.
</li>
</ol>
<p>
Important: step 3 looks for the name <code>IronKernel</code>, not <code>ik</code>.
If you installed Option A (global tool only), set
<code>ironkernel.executablePath</code> to the absolute path of the <code>ik</code>
shim (usually <code>~/.dotnet/tools/ik</code>), or put a release binary
directory on <code>PATH</code>.
</p>
<div class="example">
<p class="example-caption">settings.json · pin the <code>ik</code> tool or a release binary</p>
<pre><code>{
"ironkernel.executablePath": "/Users/you/.dotnet/tools/ik",
"ironkernel.profile": "unrestricted",
"ironkernel.runArgs": []
}</code></pre>
</div>
<p>
<code>.ikproj</code> files are associated with XML so VS Code highlights them as
MSBuild projects.
</p>
<p>Other useful settings:</p>
<ul>
<li>
<code>ironkernel.ikprojPath</code> — pin which <code>.ikproj</code> Run/Build Project
uses (otherwise the extension discovers the nearest project).
</li>
<li>
<code>ironkernel.profile</code> — <code>minimal</code>, <code>safe</code>, or
<code>unrestricted</code> (default).
</li>
<li>
<code>ironkernel.runArgs</code> — extra args for Run Current File / Run Project.
</li>
</ul>
<p>
Playground and run commands require a <strong>trusted</strong> workspace because
IronKernel can call into .NET. Right-click a <code>.ikproj</code> in the explorer for
Run Project / Build Project.
</p>
<h2 id="errors">8. Read errors at the source</h2>
<p>Diagnostics identify the file and range, then underline the failing form.</p>
<div class="example">
<pre><code class="language-text">demo.ikr:2:1: Getting an unbound variable: 'missing'
(missing 42)
^^^^^^^^^^^^</code></pre>
</div>
<p>
Startup, script, compile, package, and project failures go to stderr with a non-zero
exit code, so the CLI works in build tools and the VS Code Problems view.
</p>
<h2 id="capabilities">9. Choose host authority</h2>
<p>
Capability profiles decide which host operations enter the root environment.
<code>minimal</code> has no host access, <code>safe</code> exposes reviewed generated CLR
wrappers, and <code>unrestricted</code> preserves raw reflection and I/O (default).
</p>
<div class="example">
<pre><code class="language-shell">ik --profile safe hello.ikr</code></pre>
</div>
<h2 id="effects">10. Handle effects and await tasks</h2>
<p>
Unforgeable prompt tags let handlers intercept only their own operations.
A handler can abort the captured computation or resume it once; resumption reinstalls
the same handler for later operations.
</p>
<div class="example">
<pre><code>(define request (make-prompt-tag))
(prompt request
(lambda (value k) (resume k (+ value 1)))
(+ 1 (perform request 40)))
; ⇒ 42
(await-task (task-delay 25 "ready"))</code></pre>
</div>
<p>
Async host access is available only in the <code>unrestricted</code> profile.
Task callbacks enqueue outcomes; they never run the evaluator directly.
</p>
<h2 id="contracts">11. Add contracts without changing semantics</h2>
<div class="example">
<pre><code>(define double (lambda (x) (+ x x)))
(contract double applicative (number) number pure #t)
(define raw (vau operands _ operands))
(contract raw operative (any) any pure #t)</code></pre>
</div>
<p>
User contracts remain runtime assertions. Only compiler-certified pure primitives are
partially evaluated, and every folded call retains an exact guarded fallback.
</p>
<h2 id="from-source">12. Building from source (optional)</h2>
<p>
Clone the repository when you are developing IronKernel itself or want the
example tree. Day-to-day language use should use <code>ik</code> or a release
binary from §1.
</p>
<div class="example">
<pre><code class="language-shell">git clone https://github.com/ironkernel-lang/IronKernel
cd IronKernel
dotnet build
dotnet test
dotnet run --project IronKernel -- Examples/hello.ikr</code></pre>
</div>
<p>
To exercise a local tool package before publishing:
</p>
<div class="example">
<pre><code class="language-shell">dotnet pack IronKernel/IronKernel.fsproj -c Release -o packages
dotnet tool install -g IronKernel.Tool --add-source ./packages --version 0.3.0</code></pre>
</div>
<h2 id="next">Where next?</h2>
<div class="cta-row">
<a class="btn btn-primary" href="intro.html">Understand Kernel</a>
<a class="btn btn-ghost" href="guide.html">Follow the language guide</a>
<a class="btn btn-ghost" href="https://github.com/ironkernel-lang/IronKernel/tree/master/Examples">Browse examples</a>
<a class="btn btn-ghost" href="https://github.com/ironkernel-lang/IronKernel/releases">Releases</a>
</div>
</article>
</div>
<footer class="footer">
<div class="wrap">
<span>IronKernel docs</span>
<span><a href="../index.html">Home</a> · <a href="operators.html">Operators</a></span>
</div>
</footer>
<script src="../assets/site.js"></script>
</body>
</html>