Skip to content

Commit e89abaf

Browse files
committed
Some tips about diagnostics on README
1 parent e995077 commit e89abaf

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,45 @@ assert(
6161
)
6262
```
6363

64+
## Better diagnostics
65+
Result Builders (https://developer.apple.com/videos/play/wwdc2021/10253/) are awesome, however the diagnostics in case of type mismatch or failure to
66+
infer the type expression are misleading, incomplete or confusing. Although the Swift Core Team keeps improving the diagnostics every release, you may
67+
eventually find yourself in a compiler error that is tricky to understand. In that case, you may want to use the old format, that use plain arrays.
68+
69+
```swift
70+
// Instead of:
71+
assert(
72+
// ...
73+
steps: {
74+
Send(action: .certainAction(.verySpecific))
75+
76+
SideEffectResult {
77+
scheduler.advance(by: .seconds(5))
78+
}
79+
}
80+
)
81+
82+
// You can use:
83+
assert(
84+
// ...
85+
steps: [
86+
Send(action: .certainAction(.verySpecific))
87+
.asStep,
88+
89+
SideEffectResult {
90+
scheduler.advance(by: .seconds(5))
91+
}.asStep
92+
]
93+
)
94+
```
95+
96+
For that:
97+
- replace `steps: { }` curly-brackets for square-brackets `steps: []`
98+
- add `.asStep` after each step
99+
- add comma (,) after each step, except the last
100+
101+
The syntax is not so elegant, but the diagnostics are better.
102+
64103
## Combine
65104

66105
Validate Output of Publishers

0 commit comments

Comments
 (0)