Skip to content

Commit adc238a

Browse files
dbrattliclaude
andcommitted
Fix Beam docs: compilation order, typo, and accuracy improvements
- Fix erlc compilation order in getting-started guide (runtime before user code) - Fix extra quote typo in compatibility table - Add link to Build and Run from getting-started page - Move nativeOnly section to top of Utilities for better discoverability - Clarify task/async equivalence and limitations on Beam - Fix inaccurate claim about integer handling vs Python target Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3249594 commit adc238a

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

docs/docs/beam/compatibility.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Numeric Types | Native integers and floats
4040
Arrays | Process dict refs (lists / atomics for byte[])
4141
System.Boolean | `true` / `false` atoms
4242
System.Char | Binary (string of length 1)
43-
System.String | Binary (`<<"...">>`")
43+
System.String | Binary (`<<"...">>`)
4444
System.Decimal | Custom fixed-scale integer
4545
System.DateTime | `{Ticks, Kind}` tuple
4646
System.DateTimeOffset | `{Ticks, OffsetTicks, Kind}` tuple
@@ -124,12 +124,12 @@ float32 / single | Single | `float()` | Native IEEE 754
124124
decimal | Decimal | Custom | Fixed-scale integer implementation
125125
bigint | BigInteger | `integer()` | Native (Erlang integers ARE arbitrary-precision)
126126

127-
### Erlang Advantage: No Wrapper Types Needed
127+
### Sized Integer Overflow
128128

129-
Unlike the Python target which requires custom PyO3/Rust wrapper types for sized integers (~1200 lines), Erlang handles all integer operations natively. Sized integer wrapping (when needed for overflow semantics) uses Erlang's bit syntax:
129+
Like Python, Erlang has native arbitrary-precision integers. Sized integer wrapping (for overflow semantics of `int32`, `int64`, etc.) uses Erlang's bit syntax:
130130

131131
```erlang
132-
%% Wrapping int32 arithmetic — pure Erlang, no NIF
132+
%% Wrapping int32 arithmetic
133133
wrap32(N) ->
134134
<<V:32/signed-integer>> = <<N:32/signed-integer>>,
135135
V.
@@ -159,6 +159,10 @@ F# | Erlang
159159
`Async.Sleep` | `timer:sleep(Ms)`
160160
`task { return x }` | Same as async (alias on Beam)
161161

162+
:::info
163+
`task { }` and `async { }` compile to the same CPS representation on Beam. The hot-start semantics of .NET `Task` are not preserved. Downcasting from `obj` to `Task<T>` or `Async<T>` is not supported.
164+
:::
165+
162166
### CancellationToken
163167

164168
Full cancellation support via `fable_cancellation.erl`:

docs/docs/beam/features.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ Beam target is in alpha meaning that breaking changes can happen between minor v
1313

1414
## Utilities
1515

16+
### `nativeOnly`
17+
18+
`nativeOnly` provides a dummy implementation used when writing bindings to Erlang libraries.
19+
20+
```fs
21+
[<Import("reverse", "lists")>]
22+
let reverse : 'a list -> 'a list = nativeOnly
23+
```
24+
25+
The thrown exception should never be seen as `nativeOnly` calls are replaced by actual Erlang module calls.
26+
1627
### Automatic case conversion
1728

1829
When targeting Erlang, Fable automatically converts F# camelCase names to Erlang snake_case names.
@@ -57,17 +68,6 @@ maybe_(X) -> X + 1.
5768
receive_(X) -> X * 2.
5869
```
5970

60-
### `nativeOnly`
61-
62-
`nativeOnly` provides a dummy implementation used when writing bindings to Erlang libraries.
63-
64-
```fs
65-
[<Import("lists", "reverse")>]
66-
let reverse : 'a list -> 'a list = nativeOnly
67-
```
68-
69-
The thrown exception should never be seen as `nativeOnly` calls are replaced by actual Erlang module calls.
70-
7171
## Imports
7272

7373
Fable provides attributes to import Erlang modules and functions.
@@ -289,7 +289,7 @@ Async.RunSynchronously (fetchData ())
289289

290290
- `Async.Parallel` spawns one Erlang process per computation and collects results via message passing
291291
- `Async.Sleep` uses `timer:sleep`
292-
- `task { }` is an alias for `async { }` on the Beam target
292+
- `task { }` is an alias for `async { }` on the Beam target — both compile to the same CPS representation. The hot-start semantics of .NET `Task` are not preserved. Downcasting from `obj` to `Task<T>` or `Async<T>` is not supported
293293

294294
## MailboxProcessor
295295

docs/docs/getting-started/beam.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ This generates `.erl` files in the output directory (default `./output`).
4040
Compile the generated Erlang files:
4141

4242
```bash
43-
erlc -o output output/*.erl
4443
erlc -o output/fable_modules/fable-library-beam output/fable_modules/fable-library-beam/*.erl
44+
erlc -pa output/fable_modules/fable-library-beam -o output output/*.erl
4545
```
4646

4747
</li>
@@ -67,3 +67,5 @@ dotnet fable watch --lang beam
6767
</li>
6868

6969
</ul>
70+
71+
For more details, see [Build and Run](/docs/beam/build-and-run).

0 commit comments

Comments
 (0)