File tree Expand file tree Collapse file tree
src/FSharp.Control.AsyncSeq
tests/FSharp.Control.AsyncSeq.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -868,6 +868,9 @@ module AsyncSeq =
868868 member x.For ( seq : AsyncSeq < 'T >, action : 'T -> AsyncSeq < 'TResult >) =
869869 collect action seq
870870
871+ member x.YieldFrom ( s : seq < 'T >) =
872+ ofSeq s
873+
871874 let unfoldAsync ( f : 'State -> Async <( 'T * 'State ) option >) ( s : 'State ) : AsyncSeq < 'T > =
872875 new UnfoldAsyncEnumerator<_, _>( f, s) :> _
873876
Original file line number Diff line number Diff line change @@ -112,6 +112,9 @@ module AsyncSeq =
112112 /// Implements "yield ! " for the asyncSeq computation builder.
113113 member YieldFrom : source : AsyncSeq < 'T > -> AsyncSeq < 'T >
114114
115+ /// Implements "yield ! " for a synchronous sequence in the asyncSeq computation builder.
116+ member YieldFrom : source : seq < 'T > -> AsyncSeq < 'T >
117+
115118 /// Implements empty for the asyncSeq computation builder.
116119 member Zero : unit -> AsyncSeq < 'T >
117120
Original file line number Diff line number Diff line change @@ -156,6 +156,26 @@ let ``AsyncSeq.toListSynchronously``() =
156156 Assert.True(([ 1 ; 2 ; 3 ] = a))
157157
158158
159+ [<Test>]
160+ let ``asyncSeq yield ! seq works`` () =
161+ let items = seq { 1 ; 2 ; 3 }
162+ let s = asyncSeq {
163+ yield ! items
164+ }
165+ let a = s |> AsyncSeq.toListSynchronously
166+ Assert.True(([ 1 ; 2 ; 3 ] = a))
167+
168+ [<Test>]
169+ let ``asyncSeq yield ! seq combines with other yields`` () =
170+ let items = seq { 2 ; 3 }
171+ let s = asyncSeq {
172+ yield 1
173+ yield ! items
174+ yield 4
175+ }
176+ let a = s |> AsyncSeq.toListSynchronously
177+ Assert.True(([ 1 ; 2 ; 3 ; 4 ] = a))
178+
159179[<Test>]
160180let ``AsyncSeq.concatSeq works`` () =
161181 let ls = [ [ 1 ; 2 ] ; [ 3 ; 4 ] ]
You can’t perform that action at this time.
0 commit comments