Skip to content

Commit 8dab5d0

Browse files
1eyewonderTheAngryByrd
authored andcommitted
Added BindMappings documentation to gitbook
1 parent 7266305 commit 8dab5d0

File tree

2 files changed

+51
-34
lines changed

2 files changed

+51
-34
lines changed

gitbook/BindMappings.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This pages shows you which computation expressions can implicitly bind to other CEs
44

5-
Example
5+
## Example
66

77
Here we can bind an 'T Option to 'T AsyncOption without having to lift from one type to another. See [here](https://fsharpforfunandprofit.com/posts/elevated-world/) for a better understanding on 'lifting'. To associate with the table below, the AsyncOption is the CE and the Option is the CE that can bind to it.
88

@@ -13,24 +13,39 @@ asyncOption {
1313
}
1414
```
1515

16-
*Each CE can bind to itself so we don't list that here to reduce redundancy*
17-
18-
| CE | Can Bind (FsToolkit.ErrorHandling) | Can Bind (FsToolkit.ErrorHandling.IcedTasks) | Can Bind (FsToolkit.ErrorHandling.JobResult) | Can Bind (FsToolkit.ErrorHandling.TaskResult) |
19-
|:--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|--|-----------------------------------------------|
20-
| AsyncOption | Async, Task, Option | || |
21-
| AsyncResult | Result, Choice, Async, Task | || TaskResult |
22-
| AsyncResultOption | AsyncResult, AsyncOption, Result, Choice, Async, Task, Option | || TaskResultOption, TaskResult, TaskOption |
23-
| AsyncValidation | AsyncResult, Validation, Result, Choice, Async | || |
24-
| CancellableTaskResult | AsyncResult, AsyncChoice, Result, Choice, Async, Task, | CancellableTask<sup>1</sup>, ColdTask<sup>4</sup> || ValueTaskResult, TaskResult |
25-
| CancellableTaskValidation | AsyncResult, AsyncChoice, ValueTaskResult<sup>3</sup>, TaskResult<sup>3</sup>, Validation, Result, Choice, Async, Task, CancellableTask<sup>1</sup>, ColdTask<sup>4</sup> | || |
26-
| JopOption | Job <sup>2</sup>, TaskOption <sup>3</sup>, AsyncOption | || |
27-
| JobResult | | || |
28-
| JobResultOption | | || |
29-
| Option | | || |
30-
| Result | | || |
31-
| ResultOption | | || |
32-
| Task | | || |
33-
| TaskOption | | || |
34-
| TaskResult | | || |
35-
| TaskResultOption | | || |
36-
| Validation | | || |
16+
### Note
17+
18+
Each CE can bind to itself so we don't list that here to reduce clutter
19+
20+
| CE | Can Bind |
21+
| :------------------------ | :----------------------------------------------------------------------------------------------------------------------------------------- |
22+
| AsyncOption | Async, Task, Option |
23+
| AsyncResult | Result, Choice, Async, Task, TaskResult |
24+
| AsyncResultOption | TaskResultOption, AsyncResult, TaskResult, AsyncOption, Result, Choice, Async, Task, Option, |
25+
| AsyncValidation | AsyncResult, Validation, Result, Choice, Async |
26+
| CancellableTaskResult | ValueTaskResult, AsyncResult, TaskResult, AsyncChoice, CancellableTask, ColdTask, Result, Choice, Async, Task |
27+
| CancellableTaskValidation | AsyncValidation, ValueTaskResult, AsyncResult, TaskResult, AsyncChoice, CancellableTask, ColdTask, Validation, Result, Choice, Async, Task |
28+
| JopOption | TaskOption, AsyncOption, Job, Async, Task, Option |
29+
| JobResult | AsyncResult, TaskResult, Job, Result, Choice, Async, Task |
30+
| JobResultOption | |
31+
| Option | ValueOption, nullable object |
32+
| Result | Choice |
33+
| ResultOption | |
34+
| Task | |
35+
| TaskOption | ValueTaskOption, AsyncOption, PlyOption, Async, Task, ValueTask, Option |
36+
| TaskResult | AsyncResult, PlyResult, TaskResult, ValueTaskResult, Result, Choice, Ply, Async, Task, ValueTask |
37+
| TaskResultOption | |
38+
| Validation | Result, Choice |
39+
40+
## Don't see the bindings you want?
41+
42+
Luckily the CEs are extensible so you can add your own Source overloads to the builders. Take for example the AsyncOption builder. Let's pretend it didn't support being able to bind Async values. You can add an overload as follows shown below. The code shown would go in your own codebase, unless you'd want to submit a PR 😉 If you need an example of how to do this with various syntax, check out any of the CE files in the codebase.
43+
44+
```fsharp
45+
module MyCustomCodeModule =
46+
47+
type AsyncOptionBuilder with
48+
member _.Source(value: Async<'T>) : Async<'T option> =
49+
value |> Async.map Some
50+
51+
```

gitbook/SUMMARY.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,18 @@
102102
* [Operators](cancellableTaskValidation/operators.md)
103103
* FsToolkit.ErrorHandling.JobResult
104104
* JobResult
105-
* [map](jobResult/map.md)
106-
* [map2](jobResult/map2.md)
107-
* [map3](jobResult/map3.md)
108-
* [mapError](jobResult/mapError.md)
109-
* [apply](jobResult/apply.md)
110-
* [foldResult](jobResult/foldResult.md)
111-
* [ofTask](jobResult/ofTask.md)
112-
* [bind](jobResult/bind.md)
113-
* [ignore](jobResult/ignore.md)
114-
* [Computation Expression](jobResult/ce.md)
115-
* [Operators](jobResult/operators.md)
116-
* [Other Functions](jobResult/others.md)
105+
* [map](jobResult/map.md)
106+
* [map2](jobResult/map2.md)
107+
* [map3](jobResult/map3.md)
108+
* [mapError](jobResult/mapError.md)
109+
* [apply](jobResult/apply.md)
110+
* [foldResult](jobResult/foldResult.md)
111+
* [ofTask](jobResult/ofTask.md)
112+
* [bind](jobResult/bind.md)
113+
* [ignore](jobResult/ignore.md)
114+
* [Computation Expression](jobResult/ce.md)
115+
* [Operators](jobResult/operators.md)
116+
* [Other Functions](jobResult/others.md)
117117
* FsToolkit.ErrorHandling.TaskResult
118118
* TaskResult
119119
* [map](taskResult/map.md)
@@ -144,3 +144,5 @@
144144
* [Operators](taskResultOption/operators.md)
145145
* TaskOption
146146
* [Computation Expression](taskOption/ce.md)
147+
* General Docs
148+
* [Bind Mappings](bindMappings.md)

0 commit comments

Comments
 (0)