### Example CHANGELOG.md Structure Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Format for maintaining release notes using the KeepAChangelog standard. ```markdown ## [Unreleased] ### Added - Does cool stuff! ### Fixed - Fixes that silly oversight ## [0.1.0] - 2017-03-17 First release ### Added - This release already has lots of features [Unreleased]: https://github.com/user/MyCoolNewLib.git/compare/v0.1.0...HEAD [0.1.0]: https://github.com/user/MyCoolNewLib.git/releases/tag/v0.1.0 ``` -------------------------------- ### Installing IcedTasks Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Command to add the IcedTasks NuGet package to a project. ```bash dotnet add nuget IcedTasks ``` -------------------------------- ### Install IcedTasks via NuGet Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Use the dotnet CLI to add the IcedTasks package to your F# project. ```bash dotnet add package IcedTasks ``` -------------------------------- ### AsyncEx with IAsyncEnumerable Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Demonstrates using the `for` keyword with `IAsyncEnumerable` inside `asyncEx`. This example uses `TaskSeq` but is compatible with any `IAsyncEnumerable`. ```fsharp open IcedTasks open FSharp.Control let myAsyncEx = asyncEx { let items = taskSeq { // IAsyncEnumerable yield 42 do! Task.Delay(100) yield 1701 } let mutable sum = 0 for i in items do sum <- sum + i return sum } ``` -------------------------------- ### F# Task Polyfill Examples Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Demonstrates the usage of IcedTasks.Polyfill.Task for enhanced task building, including `task` for general tasks, `taskUnit` for tasks without return values, and `backgroundTask` for thread pool execution. ```fsharp open IcedTasks.Polyfill.Task open System.Threading.Tasks // Shadow the built-in task with IcedTasks version let enhancedTaskExample = task { let! result = Task.FromResult(42) return result * 2 } ``` ```fsharp // taskUnit for Task without return value open IcedTasks let unitTaskExample = taskUnit { do! Task.Delay(100) printfn "Completed" } ``` ```fsharp // backgroundTask for thread pool execution let bgTaskExample = backgroundTask { printfn "On thread pool: %b" System.Threading.Thread.CurrentThread.IsThreadPoolThread return 42 } ``` -------------------------------- ### Directory Structure of Build Output Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Example of the typical directory structure for a compiled library's output, showing the `Debug` folder containing compiled artifacts for a specific .NET framework version. ```bash $ tree src/MyCoolNewLib/bin/ src/MyCoolNewLib/bin/ └── Debug └── net50 ├── MyCoolNewLib.deps.json ├── MyCoolNewLib.dll ├── MyCoolNewLib.pdb └── MyCoolNewLib.xml ``` -------------------------------- ### ColdTask Execution Control Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Illustrates `ColdTask` behavior where execution is deferred until explicitly called. This example verifies that a value is not set until the `coldTask` is invoked. ```fsharp open IcedTasks let coldTask_dont_start_immediately = task { let mutable someValue = null let fooColdTask = coldTask { someValue <- 42 } do! Async.Sleep(100) // ColdTasks will not execute until they are called, similar to how Async works Expect.equal someValue null "" // Calling fooColdTask will start to execute it do! fooColdTask () Expect.equal someValue 42 "" } ``` -------------------------------- ### Use coldTask for Lazy Task Evaluation Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Creates tasks that execute only when explicitly invoked, supporting re-execution. Includes examples for definition, deferred execution, re-execution, and parallel zip. ```fsharp open IcedTasks open System.Threading.Tasks // ColdTask is an alias for: unit -> Task<'T> let myColdTask: ColdTask = coldTask { printfn "Starting cold task..." do! Task.Delay(100) return 42 } // Cold tasks don't execute until called let demonstrateColdTask = task { let mutable executed = false let myLazyTask = coldTask { executed <- true return "Hello" } // Task hasn't started yet printfn "Executed: %b" executed // Output: Executed: false // Now start the task let! result = myLazyTask () printfn "Executed: %b" executed // Output: Executed: true printfn "Result: %s" result // Output: Result: Hello } // Cold tasks can be re-executed let reusableColdTask = coldTask { return System.DateTime.Now.Ticks } let runMultipleTimes = task { let! first = reusableColdTask () do! Task.Delay(10) let! second = reusableColdTask () // first and second will have different values printfn "Different executions: %b" (first <> second) } // ColdTask module functions let coldTaskExample = coldTask { let ct1 = ColdTask.singleton "hello" let ct2 = ColdTask.singleton "world" // Parallel zip starts both tasks concurrently let! (a, b) = ColdTask.parallelZip ct1 ct2 return sprintf "%s %s" a b // "hello world" } ``` -------------------------------- ### Use valueTask Computation Expression Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Creates ValueTask<'T> values to reduce heap allocations for synchronous completions. Includes examples for basic usage, consumption, async integration, and module functions. ```fsharp open IcedTasks // Basic valueTask usage let computeValueTask = valueTask { let! x = ValueTask.FromResult(10) let! y = ValueTask.FromResult(20) return x + y } // Consuming a valueTask let runValueTask = task { let! result = computeValueTask printfn "Result: %d" result // Output: Result: 30 return result } // Using valueTask with async operations let fetchDataValueTask (url: string) = valueTask { use client = new System.Net.Http.HttpClient() let! response = client.GetStringAsync(url) return response.Length } // ValueTask module functions let example = valueTask { let vt1 = ValueTask.singleton 42 let vt2 = ValueTask.singleton 8 // Map over a ValueTask let! mapped = ValueTask.map (fun x -> x * 2) vt1 // 84 // Zip two ValueTasks let! (a, b) = ValueTask.zip vt1 vt2 // (42, 8) return mapped + a + b // 134 } ``` -------------------------------- ### Initialize Git Repository Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Commands to stage, commit, and push a new project to a remote GitHub repository. ```sh git add . git commit -m "Scaffold" git remote add origin https://github.com/user/MyCoolNewLib.git git push -u origin master ``` -------------------------------- ### AsyncEx with Task/ValueTask Awaitables Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Shows how `asyncEx` allows `let!/do!` against `Task`, `ValueTask`, and other awaitable types. This simplifies asynchronous workflows by directly awaiting various task-like structures. ```fsharp open IcedTasks let myAsyncEx = asyncEx { let! _ = task { return 42 } // Task let! _ = valueTask { return 42 } // ValueTask let! _ = Task.Yield() // YieldAwaitable return 42 } ``` -------------------------------- ### Implement cancellableValueTask workflows Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Demonstrates high-performance cancellable workflows using ValueTask for synchronous completion scenarios. ```fsharp open IcedTasks open System.Threading open System.Threading.Tasks // CancellableValueTask is: CancellationToken -> ValueTask<'T> let efficientCancellableComputation : CancellableValueTask = cancellableValueTask { let! ct = CancellableValueTask.getCancellationToken () // Efficient for sync completion scenarios if ct.IsCancellationRequested then return 0 else return 42 } // Execute it let runCancellableValueTask = task { use cts = new CancellationTokenSource() let! result = efficientCancellableComputation cts.Token printfn "Result: %d" result // Output: Result: 42 } // CancellableValueTask module functions let cvtExample = cancellableValueTask { let cvt1 = CancellableValueTask.singleton 10 let cvt2 = CancellableValueTask.singleton 20 // Parallel execution let! (a, b) = CancellableValueTask.parallelZip cvt1 cvt2 return a + b // 30 } ``` -------------------------------- ### F# Integration Patterns with IcedTasks Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Illustrates how IcedTasks computation expressions can be mixed and matched, demonstrating nesting different builder types and using `and!` for parallel execution within `cancellableTask`. ```fsharp open IcedTasks open System.Threading open System.Threading.Tasks // Nest different computation types let mixedExample = cancellableTask { // Bind against regular Task let! taskResult = Task.FromResult(10) // Bind against ValueTask let! vtResult = ValueTask.FromResult(20) // Bind against ColdTask (automatically starts it) let! coldResult = coldTask { return 30 } // Bind against Async let! asyncResult = async { return 40 } return taskResult + vtResult + coldResult + asyncResult // 100 } ``` ```fsharp // Use cancellableTask with and! for parallel execution let parallelCancellableExample = cancellableTask { let! a = Task.FromResult(1) and! b = Task.FromResult(2) and! c = Task.FromResult(3) return a + b + c // 6 } ``` ```fsharp // Real-world web API handler pattern let apiHandler (getData: int -> CancellableTask) (id: int) = cancellableTask { let! ct = CancellableTask.getCancellationToken () try let! data = getData id return Ok data with | :? OperationCanceledException -> return Error "Request cancelled" | ex -> return Error ex.Message } ``` -------------------------------- ### Implement cancellableTask workflows Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Demonstrates creating, executing, and handling cancellation tokens within cancellableTask computation expressions. ```fsharp open IcedTasks open System open System.IO open System.Threading open System.Threading.Tasks // CancellableTask is an alias for: CancellationToken -> Task<'T> let writeToFile (path: string) (data: byte[]) : CancellableTask = cancellableTask { use file = File.Create(path) // Access the CancellationToken via lambda binding do! fun ct -> file.WriteAsync(data, 0, data.Length, ct) } // Alternative: explicitly get the CancellationToken let readFile (path: string) : CancellableTask = cancellableTask { let! ct = CancellableTask.getCancellationToken () use reader = new StreamReader(path) let! content = reader.ReadToEndAsync(ct) return content } // Execute a cancellableTask by providing a CancellationToken let executeWithCancellation = task { use cts = new CancellationTokenSource() cts.CancelAfter(TimeSpan.FromSeconds(5.0)) let computation = cancellableTask { do! Task.Delay(100) return "Completed!" } // Pass the token to start the cancellableTask let! result = computation cts.Token printfn "%s" result } // Using in ASP.NET context (e.g., Giraffe) let httpHandler (httpContext: Microsoft.AspNetCore.Http.HttpContext) = let myHandler = cancellableTask { let! ct = CancellableTask.getCancellationToken () // Use httpContext.RequestAborted as the cancellation token do! Task.Delay(100, ct) return "Response" } // Execute with the request's cancellation token myHandler httpContext.RequestAborted // CancellableTask module functions let cancellableTaskExample : CancellableTask = cancellableTask { let tasks = [ cancellableTask { return 1 } cancellableTask { return 2 } cancellableTask { return 3 } ] // Wait for all tasks let! results = CancellableTask.whenAll tasks return results // [| 1; 2; 3 |] } // Throttled parallel execution let throttledExample : CancellableTask = let tasks = [ for i in 1..10 -> cancellableTask { return i * 2 } ] CancellableTask.whenAllThrottled 3 tasks // Max 3 concurrent ``` -------------------------------- ### Build Script Execution Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Execute the build script on Windows using `build.cmd` or on Unix-like systems using `./build.sh`. An optional build target can be specified. ```sh > build.cmd // on windows $ ./build.sh // on unix ``` -------------------------------- ### Configure NuGet API Key Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Registers a NuGet API key with Paket for package publishing. ```sh paket config add-token "https://www.nuget.org" 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a ``` -------------------------------- ### AsyncEx Exception Handling Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Illustrates `asyncEx` exception handling, specifically how exceptions from Tasks are managed to avoid `AggregateException` and propagate the original exception. Use `try/with` for catching specific exceptions. ```fsharp let data = "lol" let inner = asyncEx { do! task { do! Task.Yield() raise (ArgumentException "foo") return data } :> Task } let outer = asyncEx { try do! inner return () with | :? ArgumentException -> // Should be this exception and not AggregationException return () | ex -> return raise (Exception("Should not throw this type of exception", ex)) ``` -------------------------------- ### Parallel Async Execution with parallelAsync Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Uses applicative and! syntax to execute multiple Async computations in parallel, reducing total execution time. ```fsharp open IcedTasks open System.Threading.Tasks // Simulate async HTTP calls let fetchUser (userId: int) = async { do! Async.Sleep(100) return sprintf "User_%d" userId } let fetchOrders (userId: int) = async { do! Async.Sleep(150) return [ sprintf "Order_1_%d" userId; sprintf "Order_2_%d" userId ] } let fetchPreferences (userId: int) = async { do! Async.Sleep(80) return Map.ofList [ "theme", "dark"; "language", "en" ] } // Execute all three in parallel using and! let getUserDashboard (userId: int) = parallelAsync { let! user = fetchUser userId and! orders = fetchOrders userId and! prefs = fetchPreferences userId return {| User = user Orders = orders Preferences = prefs |} } // Run it - total time ~150ms instead of ~330ms sequential let dashboard = getUserDashboard 123 |> Async.RunSynchronously // Result: { User = "User_123"; Orders = ["Order_1_123"; "Order_2_123"]; Preferences = map [("language", "en"); ("theme", "dark")] } // Multiple parallel operations let aggregateData = parallelAsync { let! result1 = async { return 10 } and! result2 = async { return 20 } and! result3 = async { return 30 } and! result4 = async { return 40 } return result1 + result2 + result3 + result4 // 100 } ``` -------------------------------- ### Execute Release Build Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Commands to trigger the release process via build script parameters or environment variables. ```sh ./build.sh Release 0.2.0 ``` ```sh RELEASE_VERSION=0.2.0 ./build.sh Release ``` -------------------------------- ### Executing CancellableTask with CancellationToken Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Shows how to invoke a cancellable task by providing a CancellationToken. ```fsharp let executeWriting = task { // CancellableTask is an alias for `CancellationToken -> Task<_>` so we'll need to pass in a `CancellationToken`. // For this example we'll use a `CancellationTokenSource` but if you were using something like ASP.NET, passing in `httpContext.RequestAborted` would be appropriate. use cts = new CancellationTokenSource() // call writeJunkToFile from our previous example do! writeJunkToFile cts.Token } ``` -------------------------------- ### AsyncEx with IAsyncDisposable Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Demonstrates using `use` with `IAsyncDisposable` within the `asyncEx` computation expression. Ensure `IAsyncDisposable` is correctly implemented. ```fsharp open IcedTasks let fakeDisposable () = { new IAsyncDisposable with member __.DisposeAsync() = ValueTask.CompletedTask } let myAsyncEx = asyncEx { use _ = fakeDisposable () return 42 } ``` -------------------------------- ### F# Async Extensions for Task Interoperability Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Showcases IcedTasks' extension methods for the F# `Async` module, enabling seamless interoperability with various .NET task types like `ValueTask`, `ColdTask`, and `CancellableTask`. ```fsharp open IcedTasks open System.Threading.Tasks // Await ValueTask from Async let awaitValueTaskExample = async { let vt = ValueTask.FromResult(42) let! result = Async.AwaitValueTask(vt) return result } ``` ```fsharp // Convert Async to ValueTask let asyncToValueTask (computation: Async) : ValueTask = Async.AsValueTask(computation) ``` ```fsharp // Await ColdTask from Async let awaitColdTaskExample = async { let ct = coldTask { return "cold" } let! result = Async.AwaitColdTask(ct) return result } ``` ```fsharp // Await CancellableTask from Async (uses current cancellation token) let awaitCancellableTaskExample = async { let cTask = cancellableTask { return 42 } let! result = Async.AwaitCancellableTask(cTask) return result } ``` ```fsharp // Convert Async to ColdTask let asyncToColdTask (comp: Async<'T>) : ColdTask<'T> = Async.AsColdTask(comp) ``` -------------------------------- ### Build Script with Debug Configuration Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Set the `CONFIGURATION` environment variable to `Debug` to build with debug symbols. This will add `-c Debug` to dotnet commands. ```sh CONFIGURATION=Debug ./build.sh ``` -------------------------------- ### Enhanced Async with asyncEx Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Extends F# async with IAsyncDisposable, direct Task/ValueTask binding, IAsyncEnumerable support, and unwrapped exception handling. ```fsharp open IcedTasks open System open System.Threading.Tasks // IAsyncDisposable support with use let asyncDisposableExample = asyncEx { let createAsyncDisposable () = { new IAsyncDisposable with member _.DisposeAsync() = printfn "Async disposing..." ValueTask.CompletedTask } use _ = createAsyncDisposable () return 42 } // Automatically calls DisposeAsync // Direct Task/ValueTask binding without Async.AwaitTask let mixedAsyncExample = asyncEx { let! taskResult = task { return "from task" } let! valueTaskResult = valueTask { return "from valueTask" } let! asyncResult = async { return "from async" } return sprintf "%s, %s, %s" taskResult valueTaskResult asyncResult } // IAsyncEnumerable iteration with for #r "nuget: FSharp.Control.TaskSeq" open FSharp.Control let asyncEnumerableExample = asyncEx { let items = taskSeq { yield 1 do! Task.Delay(10) yield 2 do! Task.Delay(10) yield 3 } let mutable sum = 0 for item in items do sum <- sum + item return sum // 6 } // Better exception handling - no AggregateException wrapping let exceptionExample = asyncEx { try do! task { do! Task.Yield() raise (InvalidOperationException "Test error") } return "success" with | :? InvalidOperationException as ex -> // Catches directly without AggregateException wrapper return sprintf "Caught: %s" ex.Message } // Use as polyfill to shadow built-in async open IcedTasks.Polyfill.Async // Now 'async' refers to asyncEx let polyfillExample = async { let! result = task { return 42 } // Works directly return result } ``` -------------------------------- ### Background Thread Execution with backgroundCancellableTask Source: https://context7.com/theangrybyrd/icedtasks/llms.txt Ensures execution on a background thread pool while supporting cancellation tokens. ```fsharp open IcedTasks open System.Threading open System.Threading.Tasks // Executes on thread pool, useful for CPU-bound work let cpuIntensiveWork : CancellableTask = backgroundCancellableTask { let! ct = CancellableTask.getCancellationToken () // This will run on a thread pool thread let mutable sum = 0 for i in 1..1000000 do if ct.IsCancellationRequested then return sum sum <- sum + i return sum } // Execute it let runBackground = task { use cts = new CancellationTokenSource() let! result = cpuIntensiveWork cts.Token printfn "Sum: %d" result } // Also available: backgroundColdTask let backgroundColdExample = backgroundColdTask { printfn "Running on thread pool" return Thread.CurrentThread.IsThreadPoolThread // true } ``` -------------------------------- ### ValueTask Computation Expression Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Shows how to create a `ValueTask` using the `task` computation expression, which is useful until F#'s native `valueTask` CE is merged. It demonstrates awaiting a `ValueTask` within a `task`. ```fsharp open IcedTasks let myValueTask = task { let! theAnswer = valueTask { return 42 } return theAnswer } ``` -------------------------------- ### Accessing CancellationToken in CancellableTask Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Demonstrates two methods for accessing the CancellationToken within a cancellableTask workflow. ```fsharp let writeJunkToFile = let path = Path.GetTempFileName() cancellableTask { let junk = Array.zeroCreate bufferSize use file = File.Create(path) for i = 1 to manyIterations do // You can do! directly against a function with the signature of `CancellationToken -> Task<_>` to access the context's `CancellationToken`. This is slightly more performant. do! fun ct -> file.WriteAsync(junk, 0, junk.Length, ct) } ``` ```fsharp let writeJunkToFile = let path = Path.GetTempFileName() cancellableTask { let junk = Array.zeroCreate bufferSize use file = File.Create(path) // You can bind against `CancellableTask.getCancellationToken` to get the current context's `CancellationToken`. let! ct = CancellableTask.getCancellationToken () for i = 1 to manyIterations do do! file.WriteAsync(junk, 0, junk.Length, ct) } ``` -------------------------------- ### Source Member for Task in IcedTasks Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/Explanations/Why-is-there-different-binds.md The Source member in IcedTasks provides a way to handle Task without needing separate Bind/ReturnFrom members for every supported type. It specifically targets the awaiter for Task. ```F# member inline _.Source(task: Task<'T>) = (fun (ct: CancellationToken) -> task.GetAwaiter()) ``` -------------------------------- ### Execute Async Operations in Parallel Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Use `parallelAsync` to execute multiple asynchronous operations concurrently and wait for all of them to complete. This is useful for fetching data from multiple sources simultaneously. ```fsharp open IcedTasks let exampleHttpCall url = async { // Pretend we're executing an HttpClient call return 42 } let getDataFromAFewSites = parallelAsync { let! result1 = exampleHttpCall "howManyPlantsDoIOwn" and! result2 = exampleHttpCall "whatsTheTemperature" and! result3 = exampleHttpCall "whereIsMyPhone" // Do something meaningful with results return () ``` -------------------------------- ### Bind to CancellableTask.getCancellationToken Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Bind against `CancellableTask.getCancellationToken` to retrieve the current context's `CancellationToken` within a `cancellableTask` computation. ```fsharp let writeJunkToFile = let path = Path.GetTempFileName() cancellableTask { let junk = Array.zeroCreate bufferSize use file = File.Create(path) // You can bind against `CancellableTask.getCancellationToken` to get the current context's `CancellationToken`. let! ct = CancellableTask.getCancellationToken () for i = 1 to manyIterations do do! file.WriteAsync(junk, 0, junk.Length, ct) ``` -------------------------------- ### Executing Parallel Async Workflows Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/index.md Uses parallelAsync to execute multiple asynchronous operations concurrently. ```fsharp open IcedTasks let exampleHttpCall url = async { // Pretend we're executing an HttpClient call return 42 } let getDataFromAFewSites = parallelAsync { let! result1 = exampleHttpCall "howManyPlantsDoIOwn" and! result2 = exampleHttpCall "whatsTheTemperature" and! result3 = exampleHttpCall "whereIsMyPhone" // Do something meaningful with results return () } ``` -------------------------------- ### Prevent Screen Flicker on Page Load Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/_template.html This JavaScript code checks for user's preferred color scheme and stored theme preference to set the initial theme of the application, preventing screen flicker during page load. It uses `localStorage` to persist the theme choice. ```javascript // Prevent screen flicker on page load const prefersDark = window.matchMedia("@media (prefers-color-scheme: dark)").matches; let currentTheme = localStorage.getItem('theme') ?? (prefersDark ? 'dark' : 'light'); if (currentTheme === 'dark') { window.document.documentElement.setAttribute("data-theme", 'dark'); window.document.documentElement.dataset.theme = currentTheme; } ``` -------------------------------- ### Generic Bind for Awaitables in F# Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/Explanations/Why-is-there-different-binds.md This generic Bind method handles any awaitable type that conforms to the Awaiter pattern, leveraging F#'s statically resolved type parameters for duck typing. ```F# [] member inline _.Bind< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter) and ^Awaiter :> ICriticalNotifyCompletion and ^Awaiter: (member get_IsCompleted: unit -> bool) and ^Awaiter: (member GetResult: unit -> 'TResult1)>] ( task: ^TaskLike, continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>) ) : TaskCode<'TOverall, 'TResult2> = ``` -------------------------------- ### Bind to CancellationToken in CancellableTask Source: https://github.com/theangrybyrd/icedtasks/blob/master/README.md Access the context's CancellationToken directly when binding against a function with the signature `CancellationToken -> Task<_>`. This is slightly more performant. ```fsharp let writeJunkToFile = let path = Path.GetTempFileName() cancellableTask { let junk = Array.zeroCreate bufferSize use file = File.Create(path) for i = 1 to manyIterations do // You can do! directly against a function with the signature of `CancellationToken -> Task<_>` to access the context's `CancellationToken`. This is slightly more performant. do! fun ct -> file.WriteAsync(junk, 0, junk.Length, ct) ``` -------------------------------- ### Specific Bind for Task in F# Source: https://github.com/theangrybyrd/icedtasks/blob/master/docsSrc/Explanations/Why-is-there-different-binds.md This overload is necessary to resolve ambiguity when the compiler encounters Task, which has multiple GetAwaiter methods. It explicitly targets the generic Task awaiter. ```F# member inline _.Bind ( task: Task<'TResult1>, continuation: ('TResult1 -> TaskCode<'TOverall, 'TResult2>) ) : TaskCode<'TOverall, 'TResult2> = ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.