Skip to content

Commit 6f50643

Browse files
authored
Added xml comments (#268)
1 parent 952d4ba commit 6f50643

File tree

9 files changed

+263
-10
lines changed

9 files changed

+263
-10
lines changed

src/FsToolkit.ErrorHandling/Async.fs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,56 @@
11
namespace FsToolkit.ErrorHandling
22

3+
/// <summary>
4+
/// Helper functions for working with the <c>Async</c> type.
5+
/// </summary>
36
[<RequireQualifiedAccess>]
47
module Async =
58

9+
/// <summary>
10+
/// Converts a value to an <c>Async</c> value
11+
/// </summary>
12+
/// <param name="value">The value to convert to an <c>Async</c> value.</param>
13+
/// <returns>The <c>Async</c> value.</returns>
614
let inline singleton (value: 'value) : Async<'value> =
715
value
816
|> async.Return
917

18+
/// <summary>
19+
/// Converts a value to an <c>Async</c> value
20+
/// </summary>
21+
/// <param name="value">The value to convert to an <c>Async</c> value.</param>
22+
/// <returns>The <c>Async</c> value.</returns>
1023
let inline retn (value: 'value) : Async<'value> =
1124
value
1225
|> async.Return
1326

27+
/// <summary>
28+
/// Takes a transformation function and applies it to the value of an <c>Async</c> value.
29+
/// </summary>
30+
/// <param name="binder">The function to bind over the <c>Async</c> value.</param>
31+
/// <param name="input">The <c>Async</c> value to bind over.</param>
32+
/// <returns>The result of binding the function over the <c>Async</c> value.</returns>
1433
let inline bind
1534
([<InlineIfLambda>] binder: 'input -> Async<'output>)
1635
(input: Async<'input>)
1736
: Async<'output> =
1837
async.Bind(input, binder)
1938

39+
/// <summary>
40+
/// Applies an <c>Async</c> function to an <c>Async</c> value.
41+
/// </summary>
42+
/// <param name="applier">The <c>Async</c> function to apply.</param>
43+
/// <param name="input">The <c>Async</c> value to apply the function to.</param>
44+
/// <returns>The result of applying the function to the value.</returns>
2045
let inline apply (applier: Async<'input -> 'output>) (input: Async<'input>) : Async<'output> =
2146
bind (fun f' -> bind (fun x' -> singleton (f' x')) input) applier
2247

48+
/// <summary>
49+
/// Applies a transformation to the value of an <c>Async</c> value to a new <c>Async</c> value using the provided function.
50+
/// </summary>
51+
/// <param name="mapper">The function to apply to the value of the <c>Async</c> value.</param>
52+
/// <param name="input">The <c>Async</c> value to transform.</param>
53+
/// <returns>The transformed <c>Async</c> value.</returns>
2354
let inline map
2455
([<InlineIfLambda>] mapper: 'input -> 'output)
2556
(input: Async<'input>)
@@ -31,6 +62,13 @@ module Async =
3162
)
3263
input
3364

65+
/// <summary>
66+
/// Applies a transformation to the values of two <c>Async</c> values to a new <c>Async</c> value using the provided function.
67+
/// </summary>
68+
/// <param name="mapper">The function to apply to the values of the <c>Async</c> values.</param>
69+
/// <param name="input1">The first <c>Async</c> value to transform.</param>
70+
/// <param name="input2">The second <c>Async</c> value to transform.</param>
71+
/// <returns>The transformed <c>Async</c> value.</returns>
3472
let inline map2
3573
([<InlineIfLambda>] mapper: 'input1 -> 'input2 -> 'output)
3674
(input1: Async<'input1>)
@@ -47,6 +85,14 @@ module Async =
4785
)
4886
input1
4987

88+
/// <summary>
89+
/// Applies a transformation to the values of three <c>Async</c> values to a new <c>Async</c> value using the provided function.
90+
/// </summary>
91+
/// <param name="mapper">The function to apply to the values of the <c>Async</c> values.</param>
92+
/// <param name="input1">The first <c>Async</c> value to transform.</param>
93+
/// <param name="input2">The second <c>Async</c> value to transform.</param>
94+
/// <param name="input3">The third <c>Async</c> value to transform.</param>
95+
/// <returns>The transformed <c>Async</c> value.</returns>
5096
let inline map3
5197
([<InlineIfLambda>] mapper: 'input1 -> 'input2 -> 'input3 -> 'output)
5298
(input1: Async<'input1>)
@@ -68,21 +114,47 @@ module Async =
68114
)
69115
input1
70116

117+
/// <summary>
71118
/// Takes two asyncs and returns a tuple of the pair
119+
/// </summary>
120+
/// <param name="left">The first async value.</param>
121+
/// <param name="right">The second async value.</param>
122+
/// <returns>The tuple of the pair.</returns>
72123
let inline zip (left: Async<'left>) (right: Async<'right>) : Async<'left * 'right> =
73124
bind (fun l -> bind (fun r -> singleton (l, r)) right) left
74125

126+
/// <summary>
127+
/// Operators for working with the <c>Async</c> type.
128+
/// </summary>
75129
module AsyncOperators =
76130

131+
/// <summary>
132+
/// Shorthand for <c>Async.map</c>
133+
/// </summary>
134+
/// <param name="mapper">The function to map over the <c>Async</c> value.</param>
135+
/// <param name="input">The <c>Async</c> value to map over.</param>
136+
/// <returns>The result of mapping the function over the <c>Async</c> value.</returns>
77137
let inline (<!>)
78138
([<InlineIfLambda>] mapper: 'input -> 'output)
79139
(input: Async<'input>)
80140
: Async<'output> =
81141
Async.map mapper input
82142

143+
/// <summary>
144+
/// Shorthand for <c>Async.apply</c>
145+
/// </summary>
146+
/// <param name="applier">The <c>Async</c> function to apply.</param>
147+
/// <param name="input">The <c>Async</c> value to apply the function to.</param>
148+
/// <returns>The result of applying the function to the value.</returns>
83149
let inline (<*>) (applier: Async<'input -> 'output>) (input: Async<'input>) : Async<'output> =
84150
Async.apply applier input
85151

152+
/// <summary>
153+
/// Shorthand for <c>Async.bind</c>
154+
/// </summary>
155+
/// <param name="input">The <c>Async</c> value to bind over.</param>
156+
/// <param name="binder">The function to bind over the <c>Async</c> value.</param>
157+
/// <returns>The result of binding the function over the <c>Async</c> value.</returns>
86158
let inline (>>=)
87159
(input: Async<'input>)
88160
([<InlineIfLambda>] binder: 'input -> Async<'output>)

src/FsToolkit.ErrorHandling/Option.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace FsToolkit.ErrorHandling
22

3+
/// <summary>
4+
/// Operators for working with the <c>Option</c> type.
5+
/// </summary>
36
[<RequireQualifiedAccess>]
47
module Option =
58

src/FsToolkit.ErrorHandling/OptionCE.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ module OptionCE =
131131
/// </summary>
132132
member inline _.Source(vopt: 'value voption) : 'value option = Option.ofValueOption vopt
133133

134+
/// <summary>
135+
/// The default instance of the `OptionBuilder` type.
136+
/// </summary>
134137
let option = OptionBuilder()
135138

136139
[<AutoOpen>]
@@ -176,8 +179,8 @@ module OptionExtensions =
176179
/// </summary>
177180
member inline _.Source(s: #seq<'value>) : #seq<'value> = s
178181

179-
// /// <summary>
180-
// /// Method lets us transform data types into our internal representation.
181-
// /// </summary>
182+
/// <summary>
183+
/// Method lets us transform data types into our internal representation.
184+
/// </summary>
182185
member inline _.Source(nullable: Nullable<'value>) : 'value option =
183186
Option.ofNullable nullable

src/FsToolkit.ErrorHandling/OptionOp.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@ namespace FsToolkit.ErrorHandling.Operator.Option
22

33
open FsToolkit.ErrorHandling
44

5+
/// <summary>
6+
/// Operators for working with the <c>Option</c> type.
7+
/// </summary>
58
[<AutoOpen>]
69
module Option =
10+
11+
/// <summary>
12+
/// Shorthand for <c>Option.map</c>
13+
/// </summary>
14+
/// <param name="input">The <c>Option</c> value to bind over.</param>
15+
/// <param name="binder">The function to bind over the <c>Option</c> value.</param>
16+
/// <returns>The result of binding the function over the <c>Option</c> value.</returns>
717
let inline (>>=)
818
(input: Option<'input>)
919
([<InlineIfLambda>] binder: 'input -> Option<'output>)

src/FsToolkit.ErrorHandling/Result.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace FsToolkit.ErrorHandling
22

3+
/// <summary>
4+
/// Helper functions for working with <c>Result</c> values.
5+
/// </summary>
36
[<RequireQualifiedAccess>]
47
module Result =
58

@@ -115,7 +118,7 @@ module Result =
115118
| Error err -> Error(onError err)
116119

117120
/// <summary>
118-
/// Combines two <c>Result</c> values and returns a new <c>Result</c> value.
121+
/// Applies a function to the value within a <c>Result</c> and returns a new <c>Result</c> with the output of the function.
119122
///
120123
/// Documentation is found here: <href>https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/apply</href>
121124
/// </summary>

src/FsToolkit.ErrorHandling/ResultCE.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ module ResultCE =
125125
/// <returns></returns>
126126
member inline _.Source(result: Result<'ok, 'error>) : Result<'ok, 'error> = result
127127

128+
/// <summary>
129+
/// The <c>Result</c> computation expression.
130+
/// </summary>
128131
let result = ResultBuilder()
129132

130133
[<AutoOpen>]

src/FsToolkit.ErrorHandling/ResultOp.fs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,42 @@ namespace FsToolkit.ErrorHandling.Operator.Result
22

33
open FsToolkit.ErrorHandling
44

5+
/// <summary>
6+
/// Operators for working with the <c>Result</c> type.
7+
/// </summary>
58
[<AutoOpen>]
69
module Result =
10+
11+
/// <summary>
12+
/// Shorthand for <c>Result.map</c>
13+
/// </summary>
14+
/// <param name="mapper">The function to map over the <c>Result</c> value.</param>
15+
/// <param name="input">The <c>Result</c> value to map over.</param>
16+
/// <returns>The result of mapping the function over the <c>Result</c> value.</returns>
717
let inline (<!>)
818
(([<InlineIfLambda>] mapper: 'okInput -> 'okOutput))
919
(input: Result<'okInput, 'error>)
1020
: Result<'okOutput, 'error> =
1121
Result.map mapper input
1222

23+
/// <summary>
24+
/// Shorthand for <c>Result.apply</c>
25+
/// </summary>
26+
/// <param name="applier">The <c>Result</c> value containing the function to apply.</param>
27+
/// <param name="input">The <c>Result</c> value containing the value to apply the function to.</param>
28+
/// <returns>The result of applying the function in the <c>Result</c> value to the value in the other <c>Result</c> value.</returns>
1329
let inline (<*>)
1430
(applier: Result<'okInput -> 'okOutput, 'error>)
1531
(input: Result<'okInput, 'error>)
1632
: Result<'okOutput, 'error> =
1733
Result.apply applier input
1834

35+
/// <summary>
36+
/// Shorthand for <c>Result.bind</c>
37+
/// </summary>
38+
/// <param name="input">The <c>Result</c> value to bind over.</param>
39+
/// <param name="binder">The function to bind over the <c>Result</c> value.</param>
40+
/// <returns>The result of binding the function over the <c>Result</c> value.</returns>
1941
let inline (>>=)
2042
(input: Result<'input, 'error>)
2143
([<InlineIfLambda>] binder: 'input -> Result<'okOutput, 'error>)

0 commit comments

Comments
 (0)