Skip to content

Commit ec5d9c2

Browse files
committed
Utils naming/xmldoc polish
1 parent e76f921 commit ec5d9c2

2 files changed

Lines changed: 19 additions & 23 deletions

File tree

src/FSharp.Control.TaskSeq/Utils.fs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ namespace FSharp.Control
22

33
open System.Threading.Tasks
44
open System
5-
open System.Diagnostics
6-
open System.Threading
75

86
[<AutoOpen>]
97
module ValueTaskExtensions =
@@ -24,15 +22,15 @@ module ValueTask =
2422
let inline ofSource taskSource version = ValueTask<bool>(taskSource, version)
2523
let inline ofTask (task: Task<'T>) = ValueTask<'T> task
2624

27-
let inline ignore (vtask: ValueTask<'T>) =
25+
let inline ignore (valueTask: ValueTask<'T>) =
2826
// this implementation follows Stephen Toub's advice, see:
2927
// https://github.com/dotnet/runtime/issues/31503#issuecomment-554415966
30-
if vtask.IsCompletedSuccessfully then
28+
if valueTask.IsCompletedSuccessfully then
3129
// ensure any side effect executes
32-
vtask.Result |> ignore
30+
valueTask.Result |> ignore
3331
ValueTask()
3432
else
35-
ValueTask(vtask.AsTask())
33+
ValueTask(valueTask.AsTask())
3634

3735
[<Obsolete "From version 0.4.0 onward, 'ValueTask.FromResult' is deprecated in favor of 'ValueTask.fromResult'. It will be removed in an upcoming release.">]
3836
let inline FromResult (value: 'T) = ValueTask<'T> value
@@ -72,14 +70,12 @@ module Async =
7270
let inline ofTask (task: Task<'T>) = Async.AwaitTask task
7371
let inline ofUnitTask (task: Task) = Async.AwaitTask task
7472
let inline toTask (async: Async<'T>) = task { return! async }
75-
let inline bind binder (task: Async<'T>) : Async<'U> = ExtraTopLevelOperators.async { return! binder task }
7673

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

8276
let inline map mapper (async: Async<'T>) : Async<'U> = ExtraTopLevelOperators.async {
8377
let! result = async
8478
return mapper result
8579
}
80+
81+
let inline bind binder (async: Async<'T>) : Async<'U> = ExtraTopLevelOperators.async { return! binder async }

src/FSharp.Control.TaskSeq/Utils.fsi

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ module ValueTask =
2424

2525
/// <summary>
2626
/// 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" />.
27+
/// please use <paramref name="fromResult" /> in its stead. See <see cref="T:FSharp.Control.ValueTask.fromResult" />.
2828
/// </summary>
2929
[<Obsolete "From version 0.4.0 onward, 'ValueTask.FromResult' is deprecated in favor of 'ValueTask.fromResult'. It will be removed in an upcoming release.">]
3030
val inline FromResult: value: 'T -> ValueTask<'T>
3131

3232
/// <summary>
33-
/// Initialized a new instance of <see cref="ValueTask" /> with an <see cref="IValueTaskSource" /> representing
33+
/// Initializes a new instance of <see cref="ValueTask" /> with an <see cref="IValueTaskSource" />
3434
/// representing its operation.
3535
/// </summary>
3636
val inline ofSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>
@@ -42,15 +42,18 @@ module ValueTask =
4242
[<Obsolete "From version 0.4.0 onward, 'ValueTask.ofIValueTaskSource' is deprecated in favor of 'ValueTask.ofSource'. It will be removed in an upcoming release.">]
4343
val inline ofIValueTaskSource: taskSource: IValueTaskSource<bool> -> version: int16 -> ValueTask<bool>
4444

45-
/// Creates a ValueTask form a Task<'T>
45+
/// Creates a ValueTask from a Task<'T>
4646
val inline ofTask: task: Task<'T> -> ValueTask<'T>
4747

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

5151
module Task =
5252

53-
/// Convert an Async<'T> into a Task<'T>
53+
/// Create a task from a value
54+
val inline fromResult: value: 'U -> Task<'U>
55+
56+
/// Starts a running instance of an Async<'T>, represented as a Task<'T>
5457
val inline ofAsync: async: Async<'T> -> Task<'T>
5558

5659
/// Convert a unit-task into a Task<unit>
@@ -80,9 +83,6 @@ module Task =
8083
/// Bind a Task<'T>
8184
val inline bind: binder: ('T -> #Task<'U>) -> task: Task<'T> -> Task<'U>
8285

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

8888
/// Convert an Task<'T> into an Async<'T>
@@ -91,14 +91,14 @@ module Async =
9191
/// Convert a unit-task into an Async<unit>
9292
val inline ofUnitTask: task: Task -> Async<unit>
9393

94-
/// Convert a Task<'T> into an Async<'T>
94+
/// Starts a running instance of an Async<'T>, represented as a Task<'T>
9595
val inline toTask: async: Async<'T> -> Task<'T>
9696

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

100100
/// Map an Async<'T>
101101
val inline map: mapper: ('T -> 'U) -> async: Async<'T> -> Async<'U>
102102

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

0 commit comments

Comments
 (0)