Skip to content

Commit b24a592

Browse files
committed
fix: Refactor async chapter
1 parent 7a63b3e commit b24a592

5 files changed

Lines changed: 35 additions & 17 deletions

File tree

‎.vscode/settings.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
{
22
"cSpell.words": [
3+
"aiohttp",
4+
"alfonsogarciacaro",
5+
"Buildalyzer",
36
"coro",
47
"destructures",
58
"elif",
69
"eprintln",
710
"fabletext",
11+
"failwithf",
812
"Fantomas",
913
"fastapi",
1014
"Feliz",
1115
"getcwd",
16+
"getenv",
1217
"Hashnode",
18+
"listdir",
19+
"nativeint",
20+
"ncave",
1321
"pathlib",
1422
"pyname",
1523
"Pyxpecto",

‎Fable.Literate.Tests/Fable.Literate.Tests.fsproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
1515
<PackageReference Include="YoloDev.Expecto.TestSdk" Version="0.14.3" />
1616
<PackageReference Include="Fable.Core" Version="5.0.0-beta.4" />
17-
<PackageReference Include="Fable.Python" Version="5.0.0-alpha.21.0" />
17+
<PackageReference Include="Fable.Python" Version="5.0.0-alpha.21.5" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

‎chapters/AsyncProgramming.fs‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,13 @@ There are several ways to execute an async workflow:
6060
*)
6161

6262
let runAsyncExample () =
63+
// Run synchronously (blocking) - simplest approach
64+
let result = fetchDataAsync () |> Async.RunSynchronously
65+
6366
// Start immediately (non-blocking) - Ignore discards the result
6467
fetchDataAsync () |> Async.Ignore |> Async.StartImmediate
6568

66-
// Run synchronously (blocking)
67-
let result = fetchDataAsync () |> Async.RunSynchronously
68-
69-
// Start with explicit continuations
70-
Async.StartWithContinuations(
71-
fetchDataAsync (),
72-
(fun result -> printfn $"Success: {result}"),
73-
(fun ex -> printfn $"Error: {ex.Message}"),
74-
(fun cancelled -> printfn "Cancelled")
75-
)
69+
result
7670

7771
(**
7872
### Combining Async Operations
@@ -351,6 +345,22 @@ let runWithTimeout () =
351345
return None
352346
}
353347

348+
(**
349+
### Advanced: StartWithContinuations
350+
351+
For fine-grained control over success, error, and cancellation outcomes, use
352+
`Async.StartWithContinuations`. This is useful when you need different handling paths
353+
for each case:
354+
*)
355+
356+
let runWithContinuations () =
357+
Async.StartWithContinuations(
358+
fetchDataAsync (),
359+
(fun result -> printfn $"Success: {result}"),
360+
(fun ex -> printfn $"Error: {ex.Message}"),
361+
(fun _cancelled -> printfn "Cancelled")
362+
)
363+
354364
(**
355365
## When to Use What
356366

‎chapters/Introduction.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ module Introduction
33
(**
44
# Introduction to Fable.Python
55
6+
> This post is part of the [F# Advent Calendar 2025](https://sergeytihon.com/2025/11/03/f-advent-calendar-in-english-2025/).
7+
Thank you, Sergey Tihon, for organizing this wonderful tradition that brings the F# community together every year!
8+
69
Welcome to this guide on [Fable.Python](https://github.com/fable-compiler/Fable.Python/) -
710
a compiler that transforms F# code into Python.
811
@@ -99,11 +102,8 @@ the `area` function.
99102
100103
## What's Next?
101104
102-
In the following chapters, we'll cover:
103-
104-
- **Getting Started** - Setting up your development environment
105-
- **Bindings** - Working with Python libraries from F#
106-
- **Compatibility** - Understanding what F# features are supported
105+
In the following chapters, we'll explore setting up your environment,
106+
working with Python libraries, and understanding F# compatibility with Fable.
107107
108108
Let's begin.
109109
*)

‎fable-python.fsproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<ItemGroup>
99
<PackageReference Include="Fable.Core" Version="5.0.0-beta.4" />
10-
<PackageReference Include="Fable.Python" Version="5.0.0-alpha.21.0" />
10+
<PackageReference Include="Fable.Python" Version="5.0.0-alpha.21.5" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

0 commit comments

Comments
 (0)