@@ -109,11 +109,7 @@ module internal Utils =
109109 /// when implementing the Subscribe method of IObservable interface.
110110 static member StartDisposable ( op : Async < unit >) =
111111 let ct = new System.Threading.CancellationTokenSource()
112- #if ! FABLE_ COMPILER
113112 Async.Start( op, ct.Token)
114- #else
115- Async.StartImmediate( op, ct.Token)
116- #endif
117113 { new IDisposable with
118114 member x.Dispose () = ct.Cancel() }
119115
@@ -216,16 +212,9 @@ module AsyncGenerator =
216212
217213
218214 static member Bind ( g : AsyncGenerator < 'a >, cont : unit -> AsyncGenerator < 'a >) : AsyncGenerator < 'a > =
219- #if ! FABLE_ COMPILER
220215 match g with
221216 | :? GenerateCont< 'a> as g -> GenerateCont<_>. Bind ( g.Generator, ( fun () -> GenerateCont<_>. Bind ( g.Cont(), cont)))
222217 | _ -> ( new GenerateCont< 'a>( g, cont) :> AsyncGenerator< 'a>)
223- #else
224- let g ' = g :?> GenerateCont< 'a>
225- if unbox< AsyncGenerator<_> option>( g'.Generator) .IsSome then
226- GenerateCont<_>. Bind ( g'.Generator, ( fun () -> GenerateCont<_>. Bind ( g'.Cont(), cont)))
227- else ( new GenerateCont< 'a>( g, cont) :> AsyncGenerator< 'a>)
228- #endif
229218
230219 /// Right-associating binder.
231220 let bindG ( g : AsyncGenerator < 'a >) ( cont : unit -> AsyncGenerator < 'a >) : AsyncGenerator < 'a > =
@@ -268,28 +257,14 @@ module AsyncGenerator =
268257 member __.Disposer = Some (( fun () -> ( enum :> IDisposable) .Dispose()))
269258
270259 let enumeratorFromGenerator ( g : AsyncGenerator < 'a >) : IAsyncEnumerator < 'a > =
271- #if ! FABLE_ COMPILER
272260 match g with
273261 | :? AsyncEnumeratorGenerator< 'a> as g -> g.Enumerator
274262 | _ -> ( new AsyncGeneratorEnumerator<_>( g) :> _)
275- #else
276- let g ' = g :?> AsyncEnumeratorGenerator< 'a>
277- match unbox< IAsyncEnumerator<_> option>( g'.Enumerator) with
278- | Some asyncEnumerator -> asyncEnumerator
279- | None -> ( new AsyncGeneratorEnumerator<_>( g) :> _)
280- #endif
281263
282264 let generatorFromEnumerator ( e : IAsyncEnumerator < 'a >) : AsyncGenerator < 'a > =
283- #if ! FABLE_ COMPILER
284265 match e with
285266 | :? AsyncGeneratorEnumerator< 'a> as e -> e.Generator
286267 | _ -> ( new AsyncEnumeratorGenerator<_>( e) :> _)
287- #else
288- let e ' = e :?> AsyncGeneratorEnumerator< 'a>
289- match unbox< AsyncGenerator<_> option>( e'.Generator) with
290- | Some asyncGenerator -> asyncGenerator
291- | None -> ( new AsyncEnumeratorGenerator<_>( e) :> _)
292- #endif
293268
294269 let delay ( f : unit -> AsyncSeq < 'T >) : AsyncSeq < 'T > =
295270 { new IAsyncEnumerable< 'T> with
@@ -388,11 +363,7 @@ module AsyncSeqOp =
388363
389364/// Module with helper functions for working with asynchronous sequences
390365module AsyncSeq =
391- #if FABLE_ COMPILER
392366 let inline dispose ( d : System.IDisposable ) = try d.Dispose() with _ -> ()
393- #else
394- let private dispose ( d : System.IDisposable ) = match d with null -> () | _ -> d.Dispose()
395- #endif
396367
397368 [<GeneralizableValue>]
398369 let empty < 'T > : AsyncSeq < 'T > =
@@ -728,17 +699,9 @@ module AsyncSeq =
728699 }
729700
730701 let iterAsync ( f : 'T -> Async < unit >) ( source : AsyncSeq < 'T >) =
731- #if ! FABLE_ COMPILER
732702 match source with
733703 | :? AsyncSeqOp< 'T> as source -> source.IterAsync f
734704 | _ -> iteriAsync ( fun i x -> f x) source
735- #else
736- let source ' = source :?> AsyncSeqOp< 'T>
737- match ( unbox<{| __ proto__ : {| IterAsync: (( 'T -> Async< unit>) -> Async< unit>) option |} option |}>( source')).__ proto__ with
738- | Some proto when proto.IterAsync.IsSome ->
739- source'.IterAsync f
740- | _ -> iteriAsync ( fun _ x -> f x) source
741- #endif
742705
743706 let iteri ( f : int -> 'T -> unit ) ( inp : AsyncSeq < 'T >) = iteriAsync ( fun i x -> async.Return ( f i x)) inp
744707
@@ -797,25 +760,13 @@ module AsyncSeq =
797760 // Additional combinators (implemented as async/asyncSeq computations)
798761
799762 let mapAsync f ( source : AsyncSeq < 'T >) : AsyncSeq < 'TResult > =
800- #if ! FABLE_ COMPILER
801763 match source with
802764 | :? AsyncSeqOp< 'T> as source -> source.MapAsync f
803765 | _ ->
804766 asyncSeq {
805767 for itm in source do
806768 let! v = f itm
807769 yield v }
808- #else
809- let source ' = source :?> AsyncSeqOp< 'T>
810- match ( unbox<{| __ proto__ : {| MapAsync: (( 'T -> Async<_>) -> AsyncSeq<_>) option |} option |}>( source')).__ proto__ with
811- | Some proto when proto.MapAsync.IsSome ->
812- proto.MapAsync.Value f
813- | _ ->
814- asyncSeq {
815- for itm in source do
816- let! v = f itm
817- yield v }
818- #endif
819770
820771 let mapiAsync f ( source : AsyncSeq < 'T >) : AsyncSeq < 'TResult > = asyncSeq {
821772 let i = ref 0 L
@@ -840,7 +791,6 @@ module AsyncSeq =
840791 #endif
841792
842793 let chooseAsync f ( source : AsyncSeq < 'T >) =
843- #if ! FABLE_ COMPILER
844794 match source with
845795 | :? AsyncSeqOp< 'T> as source -> source.ChooseAsync f
846796 | _ ->
@@ -850,19 +800,6 @@ module AsyncSeq =
850800 match v with
851801 | Some v -> yield v
852802 | _ -> () }
853- #else
854- let source ' = source :?> AsyncSeqOp< 'T>
855- match ( unbox<{| __ proto__ : {| ChooseAsync: (( 'T -> Async<_ option>) -> AsyncSeq<_>) option |} option |}>( source')).__ proto__ with
856- | Some proto when proto.ChooseAsync.IsSome ->
857- source'.ChooseAsync f
858- | _ ->
859- asyncSeq {
860- for itm in source do
861- let! v = f itm
862- match v with
863- | Some v -> yield v
864- | _ -> () }
865- #endif
866803
867804 let ofSeqAsync ( source : seq < Async < 'T >>) : AsyncSeq < 'T > =
868805 asyncSeq {
@@ -987,17 +924,9 @@ module AsyncSeq =
987924 source |> exists ( f >> not ) |> Async.map not
988925
989926 let foldAsync f ( state : 'State ) ( source : AsyncSeq < 'T >) =
990- #if ! FABLE_ COMPILER
991927 match source with
992928 | :? AsyncSeqOp< 'T> as source -> source.FoldAsync f state
993929 | _ -> source |> scanAsync f state |> lastOrDefault state
994- #else
995- let source ' = source :?> AsyncSeqOp< 'T>
996- match ( unbox<{| __ proto__ : {| FoldAsync: (( 'State -> 'T -> Async< 'State>) -> 'State -> Async< 'State>) option |} option |}>( source')).__ proto__ with
997- | Some proto when proto.FoldAsync.IsSome ->
998- proto.FoldAsync.Value f state
999- | _ -> source |> scanAsync f state |> lastOrDefault state
1000- #endif
1001930
1002931 let fold f ( state : 'State ) ( source : AsyncSeq < 'T >) =
1003932 foldAsync ( fun st v -> f st v |> async.Return) state source
0 commit comments