You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/extensions.markdown
+70Lines changed: 70 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -243,3 +243,73 @@ Other notable operations include:
243
243
-`Match` — pattern-matches on the sequence based on its count (empty, single, multiple)
244
244
245
245
These operations work together with the Funk types to enable fully functional pipelines over collections — no statements, no null checks, no surprises.
246
+
247
+
## Boolean extensions
248
+
249
+
Funk provides pattern matching and lifting for boolean values.
250
+
251
+
`Match` on booleans provides a concise way to branch on `true` and `false` without `if-else` statements.
252
+
253
+
```c#
254
+
varlabel=isActive.Match(
255
+
_=>"Inactive",
256
+
_=>"Active"
257
+
); // string
258
+
```
259
+
260
+
`AsTrue` lifts a boolean into a `Maybe<bool>`. If the value is `true`, it returns a non-empty `Maybe`. If `false` (or `null` for nullable booleans), it returns an empty `Maybe`. This enables integration with the rest of the `Maybe` pipeline.
261
+
262
+
```c#
263
+
varauthorized=user.IsAdmin.AsTrue()
264
+
.Map(_=>LoadAdminPanel()); // Maybe<Panel> — empty if not admin
Funk provides applicative functor operations for both `Maybe` and `Exc`. These are documented in detail on their respective type pages — see [Maybe applicative](/Funk/types/maybe/#applicative-applicative-functor) and [Exc applicative](/Funk/types/exc/#applicative-applicative-functor).
302
+
303
+
In summary:
304
+
305
+
-**`Apply`** (monadic) — short-circuits on the first empty/failed value. Use when later arguments depend on earlier ones.
306
+
-**`Validate`** (applicative) — accumulates all errors. Use for validation scenarios where you want to report all problems at once.
0 commit comments