Skip to content

Functions for working with TaskSeq and Channel? #415

Closed

Description

@njlr

Similar to fsprojects/FSharp.Control.AsyncSeq#170

TaskSeq.toChannel : ChannelWriter<'a> -> TaskSeq<'a> -> Task<unit>

TaskSeq.fromChannel : ChannelReader<'a> -> TaskSeq<'a>

TaskSeq.toChannel would be used to fill a ChannelWriter from a TaskSeq

TaskSeq.fromChannel would be used to empty a ChannelReader into a TaskSeq

Activity

  1. added
    enhancement
    on Apr 29, 2026
  2. github-actions commented on Apr 29, 2026

    @github-actions
  3. added a commit that references this issue on Apr 30, 2026
    59c45f7
  4. github-actions commented on Apr 30, 2026

    @github-actions
    Contributor

    🤖 This is an automated response from Repo Assist.

    I've implemented TaskSeq.toChannelAsync and TaskSeq.ofChannel and submitted a draft PR — [Repo Assist] feat: add TaskSeq.toChannelAsync and TaskSeq.ofChannel for System.Threading.Channels integration.

    What was implemented:

    // Write all elements of a TaskSeq to a ChannelWriter, then mark it complete.
    // Exceptions are propagated to the channel so downstream readers observe them.
    TaskSeq.toChannelAsync : ChannelWriter<'T> -> TaskSeq<'T> -> Task
    
    // Create a TaskSeq from a ChannelReader. Ends naturally when the channel
    // is completed and fully drained.
    TaskSeq.ofChannel : ChannelReader<'T> -> TaskSeq<'T>

    Implementation notes:

    • toChannelAsync uses while! e.MoveNextAsync() + writer.WriteAsync per element; calls writer.TryComplete() on success or writer.TryComplete(exn) on failure
    • ofChannel uses the idiomatic while! reader.WaitToReadAsync() + inner while reader.TryRead(&item) drain loop
    • One new dependency: System.Threading.Channels 8.0.0 (needed for netstandard2.1; built into net5.0+)
    • 29 new tests; all 5280 tests pass

    Generated by 🌈 Repo Assist, see workflow run.

    Generated by 🌈 Repo Assist, see workflow run. Learn more.

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/repo-assist.md@96b9d4c39aa22359c0b38265927eadb31dcf4e2a
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions