Skip to content

Commit

Permalink
Doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Dec 1, 2022
1 parent 88d5c6a commit a2ae96c
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 7 deletions.
65 changes: 62 additions & 3 deletions src/IcedTasks/CancellableTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ module CancellableTasks =
/// The existence of this method permits the use of <c>let!</c> in the
/// <c>cancellableTask { ... }</c> computation expression syntax.</remarks>
///
/// <param name="task">The computation to provide an unbound result.</param>
/// <param name="getAwaiter">The computation to provide an unbound result.</param>
/// <param name="continuation">The function to bind the result of <c>computation</c>.</param>
///
/// <returns>An CancellableTask that performs a monadic bind on the result
Expand All @@ -593,7 +593,7 @@ module CancellableTasks =
and ^Awaiter: (member get_IsCompleted: unit -> bool)
and ^Awaiter: (member GetResult: unit -> 'TResult1)>
(
getAwaiter: CancellationToken -> ^Awaiter,
[<InlineIfLambda>] getAwaiter: CancellationToken -> ^Awaiter,
[<InlineIfLambda>] continuation: ('TResult1 -> CancellableTaskCode<'TOverall, 'TResult2>)
) : CancellableTaskCode<'TOverall, 'TResult2> =

Expand Down Expand Up @@ -628,12 +628,29 @@ module CancellableTasks =
)


/// <summary>Delegates to the input computation.</summary>
///
/// <remarks>The existence of this method permits the use of <c>return!</c> in the
/// <c>cancellableTask { ... }</c> computation expression syntax.</remarks>
///
/// <param name="getAwaiter">The input computation.</param>
///
/// <returns>The input computation.</returns>
[<NoEagerConstraintApplication>]
member inline this.ReturnFrom
member inline this.ReturnFrom<'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^Awaiter :> ICriticalNotifyCompletion
and ^Awaiter: (member get_IsCompleted: unit -> bool)
and ^Awaiter: (member GetResult: unit -> 'TResult1)>
([<InlineIfLambda>] getAwaiter: CancellationToken -> ^Awaiter)
: CancellableTaskCode<_, _> =
this.Bind((fun ct -> getAwaiter ct), (fun v -> this.Return v))


/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This is the identify function.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
[<NoEagerConstraintApplication>]
member inline _.Source<'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^Awaiter :> ICriticalNotifyCompletion
Expand All @@ -644,6 +661,11 @@ module CancellableTasks =
getAwaiter


/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>^TaskLike</c> into a <c>CancellationToken -> ^Awaiter</c>.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
[<NoEagerConstraintApplication>]
member inline _.Source< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
Expand All @@ -657,6 +679,11 @@ module CancellableTasks =
)


/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>CancellationToken -> ^TaskLike</c> into a <c>CancellationToken -> ^Awaiter</c>.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
[<NoEagerConstraintApplication>]
member inline _.Source< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
Expand All @@ -668,6 +695,11 @@ module CancellableTasks =
(fun ct -> (^TaskLike: (member GetAwaiter: unit -> ^Awaiter) (task ct)))


/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>unit -> ^TaskLike</c> into a <c>CancellationToken -> ^Awaiter</c>.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
[<NoEagerConstraintApplication>]
member inline _.Source< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
Expand Down Expand Up @@ -739,17 +771,44 @@ module CancellableTasks =
// High priority extensions
type CancellableTaskBuilderBase with


/// <summary>Allows the computation expression to turn other types into other types</summary>
///
/// <remarks>This is the identify function for For binds.</remarks>
///
/// <returns><c>IEnumerable</c></returns>
member inline _.Source(s: #seq<_>) : #seq<_> = s


/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>Task&lt;'T&gt;</c> into a <c>CancellationToken -> ^Awaiter</c>.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
member inline _.Source(task: Task<'T>) =
(fun (ct: CancellationToken) -> task.GetAwaiter())

/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>ColdTask&lt;'T&gt;</c> into a <c>CancellationToken -> ^Awaiter</c>.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
member inline _.Source(task: ColdTask<'TResult1>) =
(fun (ct: CancellationToken) -> (task ()).GetAwaiter())

/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>CancellableTask&lt;'T&gt;</c> into a <c>CancellationToken -> ^Awaiter</c>.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
member inline _.Source(task: CancellableTask<'TResult1>) =
(fun ct -> (task ct).GetAwaiter())

/// <summary>Allows the computation expression to turn other types into <c>CancellationToken -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>Async&lt;'T&gt;</c> into a <c>CancellationToken -> ^Awaiter</c>.</remarks>
///
/// <returns><c>CancellationToken -> ^Awaiter</c></returns>
member inline this.Source(computation: Async<'TResult1>) =
this.Source(Async.AsCancellableTask(computation))

Expand Down
67 changes: 63 additions & 4 deletions src/IcedTasks/ColdTask.fs
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,20 @@ module ColdTasks =
sm.ResumptionDynamicInfo.ResumptionFunc <- cont
false

/// <summary>
/// The entry point for the dynamic implementation of the corresponding operation. Do not use directly, only used when executing quotations that involve tasks or other reflective execution of F# code.
/// </summary>

/// <summary>Creates an ColdTask that runs <c>computation</c>, and when
/// <c>computation</c> generates a result <c>T</c>, runs <c>binder res</c>.</summary>
///
/// <remarks>A cancellation check is performed when the computation is executed.
///
/// The existence of this method permits the use of <c>let!</c> in the
/// <c>coldTask { ... }</c> computation expression syntax.</remarks>
///
/// <param name="getAwaiter">The computation to provide an unbound result.</param>
/// <param name="continuation">The function to bind the result of <c>computation</c>.</param>
///
/// <returns>An ColdTask that performs a monadic bind on the result
/// of <c>computation</c>.</returns>
[<NoEagerConstraintApplication>]
member inline _.Bind<'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^Awaiter :> ICriticalNotifyCompletion
Expand Down Expand Up @@ -533,12 +544,29 @@ module ColdTasks =
//-- RESUMABLE CODE END
)

/// <summary>Delegates to the input computation.</summary>
///
/// <remarks>The existence of this method permits the use of <c>return!</c> in the
/// <c>coldTask { ... }</c> computation expression syntax.</remarks>
///
/// <param name="getAwaiter">The input computation.</param>
///
/// <returns>The input computation.</returns>
[<NoEagerConstraintApplication>]
member inline this.ReturnFrom
member inline this.ReturnFrom<'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^Awaiter :> ICriticalNotifyCompletion
and ^Awaiter: (member get_IsCompleted: unit -> bool)
and ^Awaiter: (member GetResult: unit -> 'TResult1)>
([<InlineIfLambda>] getAwaiter: unit -> ^Awaiter)
: ColdTaskCode<_, _> =
this.Bind((fun () -> getAwaiter ()), (fun v -> this.Return v))


/// <summary>Allows the computation expression to turn other types into <c>unit -> ^Awaiter</c></summary>
///
/// <remarks>This is the identify function.</remarks>
///
/// <returns><c>unit -> ^Awaiter</c></returns>
[<NoEagerConstraintApplication>]
member inline _.Source<'TResult1, 'TResult2, ^Awaiter, 'TOverall
when ^Awaiter :> ICriticalNotifyCompletion
Expand All @@ -548,6 +576,11 @@ module ColdTasks =
: unit -> ^Awaiter =
getAwaiter

/// <summary>Allows the computation expression to turn other types into <c>unit -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>^TaskLike</c> into a <c>unit -> ^Awaiter</c>.</remarks>
///
/// <returns><c>unit -> ^Awaiter</c></returns>
[<NoEagerConstraintApplication>]
member inline this.Source< ^TaskLike, ^Awaiter, 'T
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
Expand All @@ -558,6 +591,11 @@ module ColdTasks =
: unit -> ^Awaiter =
(fun () -> (^TaskLike: (member GetAwaiter: unit -> ^Awaiter) (task)))

/// <summary>Allows the computation expression to turn other types into <c>unit -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>unit -> ^TaskLike</c> into a <c>unit -> ^Awaiter</c>.</remarks>
///
/// <returns><c>unit -> ^Awaiter</c></returns>
[<NoEagerConstraintApplication>]
member inline this.Source< ^TaskLike, ^Awaiter, 'T
when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter)
Expand Down Expand Up @@ -618,13 +656,34 @@ module ColdTasks =

type ColdTaskBuilderBase with

/// <summary>Allows the computation expression to turn other types into other types</summary>
///
/// <remarks>This is the identify function for For binds.</remarks>
///
/// <returns><c>IEnumerable</c></returns>
member inline _.Source(s: #seq<_>) : #seq<_> = s


/// <summary>Allows the computation expression to turn other types into <c>unit -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>Task&lt;'T&gt;</c> into a <c>unit -> ^Awaiter</c>.</remarks>
///
/// <returns><c>unit -> ^Awaiter</c></returns>
member inline _.Source(task: Task<'TResult1>) = (fun () -> task.GetAwaiter())

/// <summary>Allows the computation expression to turn other types into <c>unit -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>ColdTask&lt;'T&gt;</c> into a <c>unit -> ^Awaiter</c>.</remarks>
///
/// <returns><c>unit -> ^Awaiter</c></returns>
member inline _.Source([<InlineIfLambda>] task: ColdTask<'TResult1>) =
(fun () -> (task ()).GetAwaiter())

/// <summary>Allows the computation expression to turn other types into <c>unit -> ^Awaiter</c></summary>
///
/// <remarks>This turns a <c>Async&lt;'T&gt;</c> into a <c>unit -> ^Awaiter</c>.</remarks>
///
/// <returns><c>unit -> ^Awaiter</c></returns>
member inline this.Source(computation: Async<'TResult1>) =
this.Source(Async.AsColdTask(computation))

Expand Down

0 comments on commit a2ae96c

Please sign in to comment.