Skip to content

Commit f6ff7ab

Browse files
authored
Merge pull request #249 from bartelink/util-doc
Utils naming/xmldoc polish
2 parents e76f921 + b4ce4ee commit f6ff7ab

File tree

4 files changed

+35
-43
lines changed

4 files changed

+35
-43
lines changed

src/FSharp.Control.TaskSeq/TaskSeq.fsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ type TaskSeq =
274274
static member append: source1: TaskSeq<'T> -> source2: TaskSeq<'T> -> TaskSeq<'T>
275275

276276
/// <summary>
277-
/// Concatenates a task sequence <paramref name="source1" /> with a non-async F# <see cref="seq" /> in <paramref name="source2" />
277+
/// Concatenates a task sequence <paramref name="source1" /> with a (non-async) F# <see cref="seq" /> in <paramref name="source2" />
278278
/// and returns a single task sequence.
279279
/// </summary>
280280
///
@@ -285,7 +285,7 @@ type TaskSeq =
285285
static member appendSeq: source1: TaskSeq<'T> -> source2: seq<'T> -> TaskSeq<'T>
286286

287287
/// <summary>
288-
/// Concatenates a non-async F# <see cref="seq" /> in <paramref name="source1" /> with a task sequence in <paramref name="source2" />
288+
/// Concatenates a (non-async) F# <see cref="seq" /> in <paramref name="source1" /> with a task sequence in <paramref name="source2" />
289289
/// and returns a single task sequence.
290290
/// </summary>
291291
///

src/FSharp.Control.TaskSeq/TaskSeqBuilder.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ module LowPriority =
525525
// and we need a way to distinguish these two methods.
526526
//
527527
// Types handled:
528-
// - ValueTask (non-generic, because it implements GetResult() -> unit)
528+
// - (non-generic) ValueTask (because it implements GetResult() -> unit)
529529
// - ValueTask<'T> (because it implements GetResult() -> 'TResult)
530-
// - Task (non-generic, because it implements GetResult() -> unit)
530+
// - (non-generic) Task (because it implements GetResult() -> unit)
531531
// - any other type that implements GetAwaiter()
532532
//
533533
// Not handled:

src/FSharp.Control.TaskSeq/Utils.fs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,38 @@
11
namespace FSharp.Control
22

3-
open System.Threading.Tasks
43
open System
5-
open System.Diagnostics
6-
open System.Threading
4+
open System.Threading.Tasks
75

86
[<AutoOpen>]
97
module ValueTaskExtensions =
10-
/// Extensions for ValueTask that are not available in NetStandard 2.1, but are
11-
/// available in .NET 5+. We put them in Extension space to mimic the behavior of NetStandard 2.1
128
type ValueTask with
13-
14-
/// (Extension member) Gets a task that has already completed successfully.
159
static member inline CompletedTask =
16-
// This mimics how it is done in .NET itself
10+
// This mimics how it is done in net5.0 and later internally
1711
Unchecked.defaultof<ValueTask>
1812

19-
2013
module ValueTask =
2114
let False = ValueTask<bool>()
2215
let True = ValueTask<bool> true
2316
let inline fromResult (value: 'T) = ValueTask<'T> value
2417
let inline ofSource taskSource version = ValueTask<bool>(taskSource, version)
2518
let inline ofTask (task: Task<'T>) = ValueTask<'T> task
2619

27-
let inline ignore (vtask: ValueTask<'T>) =
20+
let inline ignore (valueTask: ValueTask<'T>) =
2821
// this implementation follows Stephen Toub's advice, see:
2922
// https://github.com/dotnet/runtime/issues/31503#issuecomment-554415966
30-
if vtask.IsCompletedSuccessfully then
23+
if valueTask.IsCompletedSuccessfully then
3124
// ensure any side effect executes
32-
vtask.Result |> ignore
25+
valueTask.Result |> ignore
3326
ValueTask()
3427
else
35-
ValueTask(vtask.AsTask())
28+
ValueTask(valueTask.AsTask())
3629

3730
[<Obsolete "From version 0.4.0 onward, 'ValueTask.FromResult' is deprecated in favor of 'ValueTask.fromResult'. It will be removed in an upcoming release.">]
3831
let inline FromResult (value: 'T) = ValueTask<'T> value
3932

4033
[<Obsolete "From version 0.4.0 onward, 'ValueTask.ofIValueTaskSource' is deprecated in favor of 'ValueTask.ofSource'. It will be removed in an upcoming release.">]
4134
let inline ofIValueTaskSource taskSource version = ofSource taskSource version
4235

43-
4436
module Task =
4537
let inline fromResult (value: 'U) : Task<'U> = Task.FromResult value
4638
let inline ofAsync (async: Async<'T>) = task { return! async }
@@ -72,14 +64,12 @@ module Async =
7264
let inline ofTask (task: Task<'T>) = Async.AwaitTask task
7365
let inline ofUnitTask (task: Task) = Async.AwaitTask task
7466
let inline toTask (async: Async<'T>) = task { return! async }
75-
let inline bind binder (task: Async<'T>) : Async<'U> = ExtraTopLevelOperators.async { return! binder task }
7667

77-
let inline ignore (async': Async<'T>) = async {
78-
let! _ = async'
79-
return ()
80-
}
68+
let inline ignore (async: Async<'T>) = Async.Ignore async
8169

8270
let inline map mapper (async: Async<'T>) : Async<'U> = ExtraTopLevelOperators.async {
8371
let! result = async
8472
return mapper result
8573
}
74+
75+
let inline bind binder (async: Async<'T>) : Async<'U> = ExtraTopLevelOperators.async { return! binder async }

src/FSharp.Control.TaskSeq/Utils.fsi

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ open System.Threading.Tasks.Sources
66

77
[<AutoOpen>]
88
module ValueTaskExtensions =
9-
type System.Threading.Tasks.ValueTask with
109

11-
/// (Extension member) Gets a task that has already completed successfully.
12-
static member inline CompletedTask: System.Threading.Tasks.ValueTask
10+
/// Shims back-filling .NET 5+ functionality for use on netstandard2.1
11+
type ValueTask with
12+
13+
/// (Extension member) Gets a ValueTask that has already completed successfully.
14+
static member inline CompletedTask: ValueTask
1315

1416
module ValueTask =
1517

@@ -24,13 +26,13 @@ module ValueTask =
2426

2527
/// <summary>
2628
/// The function <paramref name="FromResult" /> is deprecated since version 0.4.0,
27-
/// please use <paramref name="fromSource" /> in its stead. See <see cref="T:FSharp.Control.ValueTask.fromResult" />.
29+
/// please use <paramref name="fromResult" /> in its stead. See <see cref="T:FSharp.Control.ValueTask.fromResult" />.
2830
/// </summary>
2931
[<Obsolete "From version 0.4.0 onward, 'ValueTask.FromResult' is deprecated in favor of 'ValueTask.fromResult'. It will be removed in an upcoming release.">]
3032
val inline FromResult: value: 'T -> ValueTask<'T>
3133

3234
/// <summary>
33-
/// Initialized a new instance of <see cref="ValueTask" /> with an <see cref="IValueTaskSource" /> representing
35+
/// Initializes a new instance of <see cref="ValueTask" /> with an <see cref="IValueTaskSource" />
3436
/// representing its operation.
3537
/// </summary>
3638
val inline ofSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>
@@ -42,21 +44,24 @@ module ValueTask =
4244
[<Obsolete "From version 0.4.0 onward, 'ValueTask.ofIValueTaskSource' is deprecated in favor of 'ValueTask.ofSource'. It will be removed in an upcoming release.">]
4345
val inline ofIValueTaskSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>
4446

45-
/// Creates a ValueTask form a Task<'T>
47+
/// Creates a ValueTask from a Task<'T>
4648
val inline ofTask: task: Task<'T> -> ValueTask<'T>
4749

48-
/// Ignore a ValueTask<'T>, returns a non-generic ValueTask.
49-
val inline ignore: vtask: ValueTask<'T> -> ValueTask
50+
/// Convert a ValueTask<'T> into a non-generic ValueTask, ignoring the result
51+
val inline ignore: valueTask: ValueTask<'T> -> ValueTask
5052

5153
module Task =
5254

53-
/// Convert an Async<'T> into a Task<'T>
55+
/// Creates a Task<'U> that's completed successfully with the specified result.
56+
val inline fromResult: value: 'U -> Task<'U>
57+
58+
/// Starts the `Async<'T>` computation, returning the associated `Task<'T>`
5459
val inline ofAsync: async: Async<'T> -> Task<'T>
5560

56-
/// Convert a unit-task into a Task<unit>
61+
/// Convert a non-generic Task into a Task<unit>
5762
val inline ofTask: task': Task -> Task<unit>
5863

59-
/// Convert a non-task function into a task-returning function
64+
/// Convert a plain function into a task-returning function
6065
val inline apply: func: ('a -> 'b) -> ('a -> Task<'b>)
6166

6267
/// Convert a Task<'T> into an Async<'T>
@@ -66,8 +71,8 @@ module Task =
6671
val inline toValueTask: task: Task<'T> -> ValueTask<'T>
6772

6873
/// <summary>
69-
/// Convert a ValueTask&lt;'T> to a Task&lt;'T>. To use a non-generic ValueTask,
70-
/// consider using: <paramref name="myValueTask |> Task.ofValueTask |> Task.ofTask" />.
74+
/// Convert a ValueTask&lt;'T> to a Task&lt;'T>. For a non-generic ValueTask,
75+
/// consider: <paramref name="myValueTask |> Task.ofValueTask |> Task.ofTask" />.
7176
/// </summary>
7277
val inline ofValueTask: valueTask: ValueTask<'T> -> Task<'T>
7378

@@ -80,25 +85,22 @@ module Task =
8085
/// Bind a Task<'T>
8186
val inline bind: binder: ('T -> #Task<'U>) -> task: Task<'T> -> Task<'U>
8287

83-
/// Create a task from a value
84-
val inline fromResult: value: 'U -> Task<'U>
85-
8688
module Async =
8789

8890
/// Convert an Task<'T> into an Async<'T>
8991
val inline ofTask: task: Task<'T> -> Async<'T>
9092

91-
/// Convert a unit-task into an Async<unit>
93+
/// Convert a non-generic Task into an Async<unit>
9294
val inline ofUnitTask: task: Task -> Async<unit>
9395

94-
/// Convert a Task<'T> into an Async<'T>
96+
/// Starts the `Async<'T>` computation, returning the associated `Task<'T>`
9597
val inline toTask: async: Async<'T> -> Task<'T>
9698

9799
/// Convert an Async<'T> into an Async<unit>, ignoring the result
98-
val inline ignore: async': Async<'T> -> Async<unit>
100+
val inline ignore: async: Async<'T> -> Async<unit>
99101

100102
/// Map an Async<'T>
101103
val inline map: mapper: ('T -> 'U) -> async: Async<'T> -> Async<'U>
102104

103105
/// Bind an Async<'T>
104-
val inline bind: binder: (Async<'T> -> Async<'U>) -> task: Async<'T> -> Async<'U>
106+
val inline bind: binder: (Async<'T> -> Async<'U>) -> async: Async<'T> -> Async<'U>

0 commit comments

Comments
 (0)