rspeele / TaskBuilder.fs

F# computation expression builder for System.Threading.Tasks
Creative Commons Zero v1.0 Universal
237 stars 27 forks source link

Added generic overload of TaskBuilderV2.For method #32

Open SLAVONchick opened 4 years ago

SLAVONchick commented 4 years ago

This PR solves problem of iterating over sequences that don't implement IEnumerable<'T>, e.g. System.Buffers.ReadOnlySequence<'T>.

After applying the changes you should be able to compile code like this:

open System.Text
open System.Buffers
open FSharp.Control.Tasks.V2

let readFromSequence (seq: ReadOnlySequence<byte>) = task {
    for segment in seq do 
        printfn "%s" <| Encoding.UTF8.GetString segment.Span
}

Please, @rspeele, give some feedback.