Skip to content

Commit d34327f

Browse files
committed
Removed commented code remnants from recent v5 changes
1 parent acfc7a5 commit d34327f

File tree

4 files changed

+6
-575
lines changed

4 files changed

+6
-575
lines changed

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskOption.fs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -626,36 +626,3 @@ module TaskOptionCEExtensionsHighPriority =
626626
this.Bind(task, (fun v -> this.Return v))
627627

628628
member inline _.Source(s: #seq<_>) = s
629-
630-
// [<AutoOpen>]
631-
// module TaskOptionCEExtensionsMediumPriority =
632-
633-
// // Medium priority extensions
634-
// type TaskOptionBuilderBase with
635-
636-
// member inline this.Source(t: Task<'T>) : CancellableTaskOption<'T> =
637-
// t
638-
// |> Task.map Some
639-
640-
// member inline this.Source(t: Task) : CancellableTaskOption<unit> =
641-
// task {
642-
// do! t
643-
// return Some()
644-
// }
645-
646-
// member inline this.Source(t: ValueTask<'T>) : CancellableTaskOption<'T> =
647-
// t
648-
// |> Task.mapV Some
649-
650-
// member inline this.Source(t: ValueTask) : CancellableTaskOption<unit> =
651-
// task {
652-
// do! t
653-
// return Some()
654-
// }
655-
656-
// member inline this.Source(opt: Option<'T>) : CancellableTaskOption<'T> = Task.FromResult opt
657-
658-
// member inline this.Source(computation: Async<'T>) : CancellableTaskOption<'T> =
659-
// computation
660-
// |> Async.map Some
661-
// |> Async.StartImmediateAsTask

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultBuilderBase.fs

Lines changed: 0 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -761,124 +761,13 @@ module CancellableTaskResultBuilderBase =
761761
: CancellableTaskResultBuilderBaseCode<_, _, _, 'Builder> =
762762
this.Bind(awaiterT = awaiterT, continuation = (fun v -> this.Return v))
763763

764-
// [<NoEagerConstraintApplication>]
765-
// member inline this.BindReturn
766-
// (
767-
// awaiterT: 'Awaiter,
768-
// [<InlineIfLambda>] mapper: 'a -> 'TResult2
769-
// ) : CancellableTaskResultBuilderBaseCode<'TResult2, 'TResult2, 'Error, 'Builder> =
770-
// this.Bind(awaiterT = awaiterT, continuation = (fun v -> this.Return(mapper v)))
771-
772764

773765
/// <exclude/>
774766
[<AutoOpen>]
775767
module LowPriority =
776768
// Low priority extensions
777769
type CancellableTaskResultBuilderBase with
778770

779-
// /// <summary>
780-
// /// 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.
781-
// /// </summary>
782-
// [<NoEagerConstraintApplication>]
783-
// static member inline BindDynamic
784-
// (
785-
// sm:
786-
// byref<ResumableStateMachine<CancellableTaskResultBuilderBaseStateMachineData<'TOverall, 'Error, 'Builder>>>,
787-
// [<InlineIfLambda>] getAwaiter: CancellationToken -> 'Awaiter,
788-
// continuation:
789-
// ('TResult1
790-
// -> CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>)
791-
// ) : bool =
792-
// sm.Data.ThrowIfCancellationRequested()
793-
794-
// let mutable awaiter = getAwaiter sm.Data.CancellationToken
795-
796-
// let cont =
797-
// (CancellableTaskResultBuilderBaseResumptionFunc<'TOverall, 'Error, _>(fun sm ->
798-
// let result = Awaiter.GetResult awaiter
799-
800-
// match result with
801-
// | Ok result -> (continuation result).Invoke(&sm)
802-
// | Error e ->
803-
// sm.Data.Result <- Error e
804-
// true
805-
// ))
806-
807-
// // shortcut to continue immediately
808-
// if Awaiter.IsCompleted awaiter then
809-
// cont.Invoke(&sm)
810-
// else
811-
// sm.ResumptionDynamicInfo.ResumptionData <-
812-
// (awaiter :> ICriticalNotifyCompletion)
813-
814-
// sm.ResumptionDynamicInfo.ResumptionFunc <- cont
815-
// false
816-
817-
// /// <summary>Creates A CancellableTask that runs computation, and when
818-
// /// computation generates a result T, runs binder res.</summary>
819-
// ///
820-
// /// <remarks>A cancellation check is performed when the computation is executed.
821-
// ///
822-
// /// The existence of this method permits the use of let! in the
823-
// /// cancellableTask { ... } computation expression syntax.</remarks>
824-
// ///
825-
// /// <param name="getAwaiter">The computation to provide an unbound result.</param>
826-
// /// <param name="continuation">The function to bind the result of computation.</param>
827-
// ///
828-
// /// <returns>A CancellableTask that performs a monadic bind on the result
829-
// /// of computation.</returns>
830-
// [<NoEagerConstraintApplication>]
831-
// member inline _.Bind
832-
// (
833-
// [<InlineIfLambda>] getAwaiterTResult: CancellationToken -> 'Awaiter,
834-
// continuation:
835-
// ('TResult1
836-
// -> CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>)
837-
// ) : CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder> =
838-
839-
// CancellableTaskResultBuilderBaseCode<'TOverall, 'TResult2, 'Error, 'Builder>(fun sm ->
840-
// if __useResumableCode then
841-
// //-- RESUMABLE CODE START
842-
// sm.Data.ThrowIfCancellationRequested()
843-
// // Get an awaiter from the Awaiter
844-
// let mutable awaiter = getAwaiterTResult sm.Data.CancellationToken
845-
846-
// let mutable __stack_fin = true
847-
848-
// if not (Awaiter.IsCompleted awaiter) then
849-
// // This will yield with __stack_yield_fin = false
850-
// // This will resume with __stack_yield_fin = true
851-
// let __stack_yield_fin = ResumableCode.Yield().Invoke(&sm)
852-
// __stack_fin <- __stack_yield_fin
853-
854-
// if __stack_fin then
855-
// let result = Awaiter.GetResult awaiter
856-
857-
// match result with
858-
// | Ok result -> (continuation result).Invoke(&sm)
859-
// | Error e ->
860-
// sm.Data.Result <- Error e
861-
// true
862-
// else
863-
// let mutable awaiter = awaiter :> ICriticalNotifyCompletion
864-
865-
// MethodBuilder.AwaitUnsafeOnCompleted(
866-
// &sm.Data.MethodBuilder,
867-
// &awaiter,
868-
// &sm
869-
// )
870-
871-
// false
872-
// else
873-
// CancellableTaskResultBuilderBase.BindDynamic(
874-
// &sm,
875-
// getAwaiterTResult,
876-
// continuation
877-
// )
878-
// //-- RESUMABLE CODE END
879-
// )
880-
881-
882771
/// <summary>Delegates to the input computation.</summary>
883772
///
884773
/// <remarks>The existence of this method permits the use of return! in the
@@ -896,16 +785,6 @@ module CancellableTaskResultBuilderBase =
896785
continuation = (fun v -> this.Return v)
897786
)
898787

899-
900-
// [<NoEagerConstraintApplication>]
901-
// member inline this.BindReturn
902-
// (
903-
// [<InlineIfLambda>] getAwaiterTResult: CancellationToken -> 'Awaiter,
904-
// mapper: 'TResult1 -> 'TResult2
905-
// ) : CancellableTaskResultBuilderBaseCode<_, _, _, _> =
906-
// this.Bind((fun ct -> getAwaiterTResult ct), (fun v -> this.Return(mapper v)))
907-
908-
909788
/// <summary>Allows the computation expression to turn other types into CancellationToken -> 'Awaiter</summary>
910789
///
911790
/// <remarks>This turns a CancellationToken -> 'Awaitable into a CancellationToken -> 'Awaiter.</remarks>
@@ -1060,18 +939,6 @@ module CancellableTaskResultBuilderBase =
1060939
: CancellableTaskResultBuilderBaseCode<_, _, _, 'Builder> =
1061940
this.Bind(awaiterTResult = awaiterTResult, continuation = (fun v -> this.Return v))
1062941

1063-
// [<NoEagerConstraintApplication>]
1064-
// member inline this.BindReturn
1065-
// (
1066-
// awaiterTResult: 'Awaiter,
1067-
// [<InlineIfLambda>] mapper: 'a -> 'TResult2
1068-
// ) : CancellableTaskResultBuilderBaseCode<'TResult2, 'TResult2, 'Error, 'Builder> =
1069-
// this.Bind(
1070-
// awaiterTResult = awaiterTResult,
1071-
// continuation = (fun v -> this.Return(mapper v))
1072-
// )
1073-
1074-
1075942
/// <summary>Allows the computation expression to turn other types into CancellationToken -> 'Awaiter</summary>
1076943
///
1077944
/// <remarks>This is the identify function.</remarks>
@@ -1214,70 +1081,6 @@ module CancellableTaskResultBuilderBase =
12141081
Async.AwaitCancellableTaskResult t
12151082

12161083

1217-
// type AsyncEx with
1218-
1219-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1220-
// /// its result.</summary>
1221-
// ///
1222-
// /// <remarks>
1223-
// /// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
1224-
// /// </remarks>
1225-
// static member inline AwaitCancellableTask
1226-
// ([<InlineIfLambda>] t: CancellationToken -> Task<'T>)
1227-
// =
1228-
// asyncEx {
1229-
// let! ct = Async.CancellationToken
1230-
// return! t ct
1231-
// }
1232-
1233-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1234-
// /// its result.</summary>
1235-
// ///
1236-
// /// <remarks>
1237-
// /// This is based on <see href="https://github.com/fsharp/fslang-suggestions/issues/840">Async.Await overload (esp. AwaitTask without throwing AggregateException)</see>
1238-
// /// </remarks>
1239-
// static member inline AwaitCancellableTask
1240-
// ([<InlineIfLambda>] t: CancellationToken -> Task)
1241-
// =
1242-
// asyncEx {
1243-
// let! ct = Async.CancellationToken
1244-
// return! t ct
1245-
// }
1246-
1247-
// type Microsoft.FSharp.Control.Async with
1248-
1249-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1250-
// /// its result.</summary>
1251-
// static member inline AwaitCancellableTask
1252-
// ([<InlineIfLambda>] t: CancellationToken -> Task<'T>)
1253-
// =
1254-
// async {
1255-
// let! ct = Async.CancellationToken
1256-
1257-
// return!
1258-
// t ct
1259-
// |> Async.AwaitTask
1260-
// }
1261-
1262-
// /// <summary>Return an asynchronous computation that will wait for the given task to complete and return
1263-
// /// its result.</summary>
1264-
// static member inline AwaitCancellableTask
1265-
// ([<InlineIfLambda>] t: CancellationToken -> Task)
1266-
// =
1267-
// async {
1268-
// let! ct = Async.CancellationToken
1269-
1270-
// return!
1271-
// t ct
1272-
// |> Async.AwaitTask
1273-
// }
1274-
1275-
// /// <summary>Runs an asynchronous computation, starting on the current operating system thread.</summary>
1276-
// static member inline AsCancellableTask
1277-
// (computation: Async<'T>)
1278-
// : CancellationToken -> Task<_> =
1279-
// fun ct -> Async.StartImmediateAsTask(computation, cancellationToken = ct)
1280-
12811084
// High priority extensions
12821085
type CancellableTaskResultBuilderBase with
12831086

src/FsToolkit.ErrorHandling.IcedTasks/CancellableTaskResultCE.fs

Lines changed: 5 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -139,58 +139,6 @@ module CancellableTaskResultCE =
139139
: CancellationToken -> Awaiter<TaskAwaiter<_>, _> =
140140
fun ct -> Awaitable.GetTaskAwaiter(x ct)
141141

142-
// member inline this.MergeSources
143-
// (
144-
// [<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
145-
// [<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
146-
// ) =
147-
// this.Run(
148-
// this.Bind(
149-
// left,
150-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
151-
// )
152-
// )
153-
// >> Awaitable.GetTaskAwaiter
154-
155-
156-
// member inline this.MergeSources
157-
// (
158-
// left: 'Awaiter1,
159-
// [<InlineIfLambda>] right: CancellationToken -> 'Awaiter2
160-
// ) =
161-
// this.Run(
162-
// this.Bind(
163-
// left,
164-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
165-
// )
166-
// )
167-
// >> Awaitable.GetTaskAwaiter
168-
169-
170-
// member inline this.MergeSources
171-
// (
172-
// [<InlineIfLambda>] left: CancellationToken -> 'Awaiter1,
173-
// right: 'Awaiter2
174-
// ) =
175-
// this.Run(
176-
// this.Bind(
177-
// left,
178-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
179-
// )
180-
// )
181-
// >> Awaitable.GetTaskAwaiter
182-
183-
184-
// member inline this.MergeSources(left: 'Awaiter1, right: 'Awaiter2) =
185-
// this.Run(
186-
// this.Bind(
187-
// left,
188-
// fun leftR -> this.BindReturn(right, (fun rightR -> struct (leftR, rightR)))
189-
// )
190-
// )
191-
// >> Awaitable.GetTaskAwaiter
192-
193-
194142
/// Contains methods to build CancellableTasks using the F# computation expression syntax
195143
type BackgroundCancellableTaskResultBuilder() =
196144

@@ -306,48 +254,12 @@ module CancellableTaskResultCE =
306254
let backgroundCancellableTaskResult = BackgroundCancellableTaskResultBuilder()
307255

308256

309-
// /// <summary>
310-
// /// A set of extension methods making it possible to bind against <see cref='T:IcedTasks.CancellableTasks.CancellableTask`1'/> in async computations.
311-
// /// </summary>
312-
// [<AutoOpen>]
313-
// module AsyncExtensions =
314-
315-
// type AsyncExBuilder with
316-
317-
// member inline this.Source([<InlineIfLambda>] t: CancellableTask<'T>) : Async<'T> =
318-
// AsyncEx.AwaitCancellableTask t
319-
320-
// member inline this.Source([<InlineIfLambda>] t: CancellableTask) : Async<unit> =
321-
// AsyncEx.AwaitCancellableTask t
322-
323-
// type Microsoft.FSharp.Control.AsyncBuilder with
324-
325-
// member inline this.Bind
326-
// (
327-
// [<InlineIfLambda>] t: CancellableTask<'T>,
328-
// [<InlineIfLambda>] binder: ('T -> Async<'U>)
329-
// ) : Async<'U> =
330-
// this.Bind(Async.AwaitCancellableTask t, binder)
331-
332-
// member inline this.ReturnFrom([<InlineIfLambda>] t: CancellableTask<'T>) : Async<'T> =
333-
// this.ReturnFrom(Async.AwaitCancellableTask t)
334-
335-
// member inline this.Bind
336-
// (
337-
// [<InlineIfLambda>] t: CancellableTask,
338-
// [<InlineIfLambda>] binder: (unit -> Async<'U>)
339-
// ) : Async<'U> =
340-
// this.Bind(Async.AwaitCancellableTask t, binder)
341-
342-
// member inline this.ReturnFrom([<InlineIfLambda>] t: CancellableTask) : Async<unit> =
343-
// this.ReturnFrom(Async.AwaitCancellableTask t)
344-
345-
// // There is explicitly no Binds for `CancellableTasks` in `Microsoft.FSharp.Control.TaskBuilderBase`.
346-
// // You need to explicitly pass in a `CancellationToken`to start it, you can use `CancellationToken.None`.
347-
// // Reason is I don't want people to assume cancellation is happening without the caller being explicit about where the CancellationToken came from.
348-
// // Similar reasoning for `IcedTasks.ColdTasks.ColdTaskBuilderBase`.
257+
// There is explicitly no Binds for `CancellableTasks` in `Microsoft.FSharp.Control.TaskBuilderBase`.
258+
// You need to explicitly pass in a `CancellationToken`to start it, you can use `CancellationToken.None`.
259+
// Reason is I don't want people to assume cancellation is happening without the caller being explicit about where the CancellationToken came from.
260+
// Similar reasoning for `IcedTasks.ColdTasks.ColdTaskBuilderBase`.
349261

350-
// // Contains a set of standard functional helper function
262+
// Contains a set of standard functional helper function
351263

352264
[<RequireQualifiedAccess>]
353265
module CancellableTaskResult =

0 commit comments

Comments
 (0)