@@ -26,6 +26,19 @@ type IAsyncSeqEnumerator<'T> =
2626 abstract MoveNext : unit -> Async < 'T option >
2727 inherit IDisposable
2828
29+ #if FABLE_ COMPILER
30+ /// AsyncSeq<'T> for Fable: a library-specific interface that avoids ValueTask.
31+ [<NoEquality; NoComparison>]
32+ type AsyncSeq < 'T > =
33+ abstract GetEnumerator : unit -> IAsyncSeqEnumerator < 'T >
34+
35+ /// Adapter: wraps an internal pull-enumerator factory into an AsyncSeq<'T>.
36+ [<Sealed>]
37+ type AsyncSeqImpl < 'T >( getEnum : unit -> IAsyncSeqEnumerator < 'T >) =
38+ member _.GetInternalEnumerator () = getEnum()
39+ interface AsyncSeq< 'T> with
40+ member _.GetEnumerator () = getEnum()
41+ #else
2942/// AsyncSeq<'T> is now the BCL IAsyncEnumerable<'T>.
3043type AsyncSeq < 'T > = System.Collections.Generic.IAsyncEnumerable< 'T>
3144
@@ -72,6 +85,7 @@ module AsyncSeqEnumeratorExtensions =
7285 else return None }
7386 interface System.IDisposable with
7487 member _.Dispose () = e.DisposeAsync() |> ignore }
88+ #endif
7589
7690#if ! FABLE_ COMPILER
7791type AsyncSeqSrc < 'a > = private { tail : AsyncSeqSrcNode < 'a > ref }
@@ -400,10 +414,16 @@ module AsyncSeqOp =
400414 | None ->
401415 return None }
402416 new UnfoldAsyncEnumerator< 'S, 'U> ( h, init) :> _
417+ #if FABLE_ COMPILER
418+ interface AsyncSeq< 'T> with
419+ member __.GetEnumerator () =
420+ new OptimizedUnfoldEnumerator< 'S, 'T>( f, init) :> IAsyncSeqEnumerator< 'T>
421+ #else
403422 interface System.Collections.Generic.IAsyncEnumerable< 'T> with
404423 member __.GetAsyncEnumerator ( ct ) =
405424 ( AsyncSeqImpl( fun () -> new OptimizedUnfoldEnumerator< 'S, 'T>( f, init) :> IAsyncSeqEnumerator< 'T>)
406425 :> System.Collections.Generic.IAsyncEnumerable< 'T>) .GetAsyncEnumerator( ct)
426+ #endif
407427
408428
409429
@@ -1921,13 +1941,15 @@ module AsyncSeq =
19211941 #if ! FABLE_ COMPILER
19221942
19231943 /// Converts a BCL IAsyncEnumerable to AsyncSeq. Identity function since AsyncSeq<'T> IS IAsyncEnumerable<'T> in v4+.
1944+ [<Obsolete( " AsyncSeq<'T> is now identical to IAsyncEnumerable<'T>. This function is a no-op and can be removed." ) >]
19241945 let ofAsyncEnum ( source : System.Collections.Generic.IAsyncEnumerable < 'T >) : AsyncSeq < 'T > = source
19251946
19261947 /// Returns the AsyncSeq as a BCL IAsyncEnumerable<'a>. Identity function since AsyncSeq<'a> IS IAsyncEnumerable<'a> in v4+.
1948+ [<Obsolete( " AsyncSeq<'T> is now identical to IAsyncEnumerable<'T>. This function is a no-op and can be removed." ) >]
19271949 let toAsyncEnum ( source : AsyncSeq < 'a >) : System.Collections.Generic.IAsyncEnumerable < 'a > = source
19281950
1929- let ofIQueryable ( query : IQueryable < 'a >) =
1930- query :?> Collections.Generic.IAsyncEnumerable< 'a> |> ofAsyncEnum
1951+ let ofIQueryable ( query : IQueryable < 'a >) : AsyncSeq < 'a > =
1952+ query :?> Collections.Generic.IAsyncEnumerable< 'a>
19311953
19321954 module AsyncSeqSrcImpl =
19331955
0 commit comments