@@ -29,15 +29,10 @@ module internal Utils =
2929 module internal Choice =
3030
3131 /// Maps over the left result type.
32- let mapl ( f : 'a -> 'b ) = function
32+ let mapl ( f : 'T -> 'U ) = function
3333 | Choice1Of2 a -> f a |> Choice1Of2
3434 | Choice2Of2 e -> Choice2Of2 e
3535
36- /// Maps over the right result type.
37- let mapr ( f : 'b -> 'c ) = function
38- | Choice1Of2 a -> Choice1Of2 a
39- | Choice2Of2 e -> f e |> Choice2Of2
40-
4136 // ----------------------------------------------------------------------------
4237
4338 module internal Observable =
@@ -75,7 +70,7 @@ module internal Utils =
7570
7671 /// Creates an async computations which runs the specified computations
7772 /// in parallel and returns their results.
78- static member Parallel ( a : Async < 'a >, b : Async < 'b >) : Async < 'a * 'b > = async {
73+ static member Parallel ( a : Async < 'T >, b : Async < 'U >) : Async < 'T * 'U > = async {
7974 let! a = a |> Async.StartChild
8075 let! b = b |> Async.StartChild
8176 let! a = a
@@ -95,10 +90,10 @@ module internal Utils =
9590 /// Creates a computation which produces a tuple consiting of the value produces by the first
9691 /// argument computation to complete and a handle to the other computation. The second computation
9792 /// to complete is memoized.
98- static member internal chooseBoth ( a : Async < 'a >) ( b : Async < 'a >) : Async < 'a * Async < 'a >> =
93+ static member internal chooseBoth ( a : Async < 'T >) ( b : Async < 'T >) : Async < 'T * Async < 'T >> =
9994 Async.FromContinuations <| fun ( ok , err , cnc ) ->
10095 let state = ref 0
101- let tcs = TaskCompletionSource< 'a >()
96+ let tcs = TaskCompletionSource< 'T >()
10297 let inline ok a =
10398 if ( Interlocked.CompareExchange( state, 1 , 0 ) = 0 ) then
10499 ok ( a, tcs.Task |> Async.AwaitTask)
@@ -134,7 +129,7 @@ module AsyncSeq =
134129
135130 /// Creates an async sequence which repeats the specified value indefinitely.
136131 let rec replicate ( v : 'T ) : AsyncSeq < 'T > =
137- Cons( v, async.Delay <| fun () -> replicate v) |> async.Return
132+ Cons( v, async.Delay ( fun () -> replicate v) ) |> async.Return
138133
139134 /// Yields all elements of the first asynchronous sequence and then
140135 /// all elements of the second asynchronous sequence.
@@ -515,7 +510,7 @@ module AsyncSeq =
515510 // --------------------------------------------------------------------------
516511
517512 /// Threads a state through the mapping over an async sequence using an async function.
518- let rec threadStateAsync ( f : 's -> 'a -> Async < 'b * 's >) ( st : 's ) ( s : AsyncSeq < 'a >) : AsyncSeq < 'b > = asyncSeq {
513+ let rec threadStateAsync ( f : 'State -> 'T -> Async < 'U * 'State >) ( st : 'State ) ( s : AsyncSeq < 'T >) : AsyncSeq < 'U > = asyncSeq {
519514 let! s = s
520515 match s with
521516 | Nil -> ()
@@ -539,7 +534,7 @@ module AsyncSeq =
539534 /// Combines two asynchronous sequences using the specified function.
540535 /// The values from sequences are retrieved in parallel.
541536 /// The resulting sequence stops when either of the argument sequences stop.
542- let rec zipWithAsync ( z : 'a -> 'b -> Async < 'c >) ( a : AsyncSeq < 'a >) ( b : AsyncSeq < 'b >) : AsyncSeq < 'c > = async {
537+ let rec zipWithAsync ( z : 'T1 -> 'T2 -> Async < 'U >) ( a : AsyncSeq < 'T1 >) ( b : AsyncSeq < 'T2 >) : AsyncSeq < 'U > = async {
543538 let! a , b = Async.Parallel( a, b)
544539 match a, b with
545540 | Cons( a, atl), Cons( b, btl) ->
@@ -550,26 +545,26 @@ module AsyncSeq =
550545 /// Combines two asynchronous sequences using the specified function.
551546 /// The values from sequences are retrieved in parallel.
552547 /// The resulting sequence stops when either of the argument sequences stop.
553- let inline zipWith ( z : 'a -> 'b -> 'c ) ( a : AsyncSeq < 'a >) ( b : AsyncSeq < 'b >) : AsyncSeq < 'c > =
548+ let inline zipWith ( z : 'T1 -> 'T2 -> 'U ) ( a : AsyncSeq < 'T1 >) ( b : AsyncSeq < 'T2 >) : AsyncSeq < 'U > =
554549 zipWithAsync ( fun a b -> z a b |> async.Return) a b
555550
556551 /// Combines two asynchronous sequences using the specified function to which it also passes the index.
557552 /// The values from sequences are retrieved in parallel.
558553 /// The resulting sequence stops when either of the argument sequences stop.
559- let zipWithIndexAsync ( f : int -> 'a -> Async < 'b >) ( s : AsyncSeq < 'a >) : AsyncSeq < 'b > =
554+ let zipWithIndexAsync ( f : int -> 'T -> Async < 'U >) ( s : AsyncSeq < 'T >) : AsyncSeq < 'U > =
560555 threadStateAsync ( fun i a -> f i a |> Async.map ( fun b -> b, i + 1 )) 0 s
561556
562557 /// Feeds an async sequence of values into an async sequence of async functions.
563- let inline zappAsync ( fs : AsyncSeq < 'a -> Async < 'b >>) ( s : AsyncSeq < 'a >) : AsyncSeq < 'b > =
558+ let inline zappAsync ( fs : AsyncSeq < 'T -> Async < 'U >>) ( s : AsyncSeq < 'T >) : AsyncSeq < 'U > =
564559 zipWithAsync (|>) s fs
565560
566561 /// Feeds an async sequence of values into an async sequence of functions.
567- let inline zapp ( fs : AsyncSeq < 'a -> 'b >) ( s : AsyncSeq < 'a >) : AsyncSeq < 'b > =
562+ let inline zapp ( fs : AsyncSeq < 'T -> 'U >) ( s : AsyncSeq < 'T >) : AsyncSeq < 'U > =
568563 zipWith (|>) s fs
569564
570565 /// Traverses an async sequence an applies to specified function such that if None is returned the traversal short-circuits
571566 /// and None is returned as the result. Otherwise, the entire sequence is traversed and the result returned as Some.
572- let rec traverseOptionAsync ( f : 'a -> Async < 'b option >) ( s : AsyncSeq < 'a >) : Async < AsyncSeq < 'b > option > = async {
567+ let rec traverseOptionAsync ( f : 'T -> Async < 'U option >) ( s : AsyncSeq < 'T >) : Async < AsyncSeq < 'U > option > = async {
573568 let! s = s
574569 match s with
575570 | Nil -> return Some ( Nil |> async.Return)
@@ -583,7 +578,7 @@ module AsyncSeq =
583578
584579 /// Traverses an async sequence an applies to specified function such that if Choice2Of2 is returned the traversal short-circuits
585580 /// and Choice2Of2 is returned as the result. Otherwise, the entire sequence is traversed and the result returned as Choice1Of2.
586- let rec traverseChoiceAsync ( f : 'a -> Async < Choice < 'b , 'e >>) ( s : AsyncSeq < 'a >) : Async < Choice < AsyncSeq < 'b >, 'e >> = async {
581+ let rec traverseChoiceAsync ( f : 'T -> Async < Choice < 'U , 'e >>) ( s : AsyncSeq < 'T >) : Async < Choice < AsyncSeq < 'U >, 'e >> = async {
587582 let! s = s
588583 match s with
589584 | Nil -> return Choice1Of2 ( Nil |> async.Return)
@@ -609,7 +604,7 @@ module AsyncSeq =
609604
610605 /// Returns elements from the argument async sequence until the specified signal completes or
611606 /// the sequences completes.
612- let rec takeUntil ( signal : Async < unit >) ( s : AsyncSeq < 'a >) : AsyncSeq < 'a > =
607+ let rec takeUntil ( signal : Async < unit >) ( s : AsyncSeq < 'T >) : AsyncSeq < 'T > =
613608 Async.chooseBoth ( signal |> Async.map Choice1Of2) ( s |> Async.map Choice2Of2)
614609 |> Async.map ( fun ( first , second ) ->
615610 match first with
@@ -632,7 +627,7 @@ module AsyncSeq =
632627 | Nil -> return Nil }
633628
634629 /// Skips elements from an async sequence until the specified signal completes.
635- let rec skipUntil ( signal : Async < unit >) ( s : AsyncSeq < 'a >) : AsyncSeq < 'a > =
630+ let rec skipUntil ( signal : Async < unit >) ( s : AsyncSeq < 'T >) : AsyncSeq < 'T > =
636631 Async.chooseBoth ( signal |> Async.map Choice1Of2) ( s |> Async.map Choice2Of2)
637632 |> Async.bind ( fun ( first , second ) ->
638633 match first with
@@ -700,13 +695,13 @@ module AsyncSeq =
700695 /// sequences are consumed in lock-step.
701696 let interleave =
702697
703- let rec left ( a : AsyncSeq < 'a >) ( b : AsyncSeq < 'b >) : AsyncSeq < Choice < _ , _ >> = async {
698+ let rec left ( a : AsyncSeq < 'T >) ( b : AsyncSeq < 'U >) : AsyncSeq < Choice < _ , _ >> = async {
704699 let! a = a
705700 match a with
706701 | Cons ( a1, t1) -> return Cons ( Choice1Of2 a1, right t1 b)
707702 | Nil -> return ! b |> map Choice2Of2 }
708703
709- and right ( a : AsyncSeq < 'a >) ( b : AsyncSeq < 'b >) : AsyncSeq < Choice < _ , _ >> = async {
704+ and right ( a : AsyncSeq < 'T >) ( b : AsyncSeq < 'U >) : AsyncSeq < Choice < _ , _ >> = async {
710705 let! b = b
711706 match b with
712707 | Cons ( a2, t2) -> return Cons ( Choice2Of2 a2, left a t2)
@@ -739,23 +734,23 @@ module AsyncSeq =
739734 }
740735
741736 /// Merges two async sequences into an async sequence non-deterministically.
742- let rec merge ( a : AsyncSeq < 'a >) ( b : AsyncSeq < 'a >) : AsyncSeq < 'a > = async {
737+ let rec merge ( a : AsyncSeq < 'T >) ( b : AsyncSeq < 'T >) : AsyncSeq < 'T > = async {
743738 let! one , other = Async.chooseBoth a b
744739 match one with
745740 | Nil -> return ! other
746741 | Cons( hd, tl) ->
747742 return Cons( hd, merge tl other) }
748743
749744 /// Merges all specified async sequences into an async sequence non-deterministically.
750- let rec mergeAll ( ss : AsyncSeq < 'a > list ) : AsyncSeq < 'a > =
745+ let rec mergeAll ( ss : AsyncSeq < 'T > list ) : AsyncSeq < 'T > =
751746 match ss with
752747 | [] -> empty
753748 | [ s] -> s
754749 | [ a; b] -> merge a b
755750 | hd:: tl -> merge hd ( mergeAll tl)
756751
757752 /// Returns an async sequence which contains no contiguous duplicate elements based on the specified comparison function.
758- let distinctUntilChangedWithAsync ( f : 'a -> 'a -> Async < bool >) ( s : AsyncSeq < 'a >) : AsyncSeq < 'a > =
753+ let distinctUntilChangedWithAsync ( f : 'T -> 'T -> Async < bool >) ( s : AsyncSeq < 'T >) : AsyncSeq < 'T > =
759754
760755 // return the head, if any, then the tail passing the previous element
761756 let rec head s =
@@ -776,11 +771,11 @@ module AsyncSeq =
776771 head s
777772
778773 /// Returns an async sequence which contains no contiguous duplicate elements based on the specified comparison function.
779- let distinctUntilChangedWith ( f : 'a -> 'a -> bool ) ( s : AsyncSeq < 'a >) : AsyncSeq < 'a > =
774+ let distinctUntilChangedWith ( f : 'T -> 'T -> bool ) ( s : AsyncSeq < 'T >) : AsyncSeq < 'T > =
780775 distinctUntilChangedWithAsync ( fun a b -> f a b |> async.Return) s
781776
782777 /// Returns an async sequence which contains no contiguous duplicate elements.
783- let distinctUntilChanged ( s : AsyncSeq < 'a >) : AsyncSeq < 'a > =
778+ let distinctUntilChanged ( s : AsyncSeq < 'T >) : AsyncSeq < 'T > =
784779 distinctUntilChangedWith ((=)) s
785780
786781
0 commit comments