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 1- ### 1.14 - 31.03.2015
1+ ### 1.15.0 - 30.03.2015
2+ * Add AsyncSeq.getIterator (unblocks use of AsyncSeq in FSharpx.Async)
3+
4+ ### 1.14 - 30.03.2015
5+ * Cancellable AsyncSeq.toBlockingSeq
6+ * Fix AsyncSeq.scanAsync to also return first state
7+ * Add a signature file
28* AsyncSeq got extracted as separate project and is now a dependency - https://github.com/fsprojects/FSharpx.Async/pull/24
39
410### 1.13 - 27.03.2015
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ open System.Reflection
44[<assembly: AssemblyTitleAttribute( " FSharp.Control.AsyncSeq" ) >]
55[<assembly: AssemblyProductAttribute( " FSharp.Control.AsyncSeq" ) >]
66[<assembly: AssemblyDescriptionAttribute( " Asynchronous sequences for F#" ) >]
7- [<assembly: AssemblyVersionAttribute( " 1.13 " ) >]
8- [<assembly: AssemblyFileVersionAttribute( " 1.13 " ) >]
7+ [<assembly: AssemblyVersionAttribute( " 1.15.0 " ) >]
8+ [<assembly: AssemblyFileVersionAttribute( " 1.15.0 " ) >]
99do ()
1010
1111module internal AssemblyVersionInformation =
12- let [<Literal>] Version = " 1.13 "
12+ let [<Literal>] Version = " 1.15.0 "
Original file line number Diff line number Diff line change @@ -286,7 +286,7 @@ module AsyncSeq =
286286 let fold f ( state : 'State ) ( input : AsyncSeq < 'T >) =
287287 foldAsync ( fun st v -> f st v |> async.Return) state input
288288
289- let rec scan f ( state : 'State ) ( input : AsyncSeq < 'T >) =
289+ let scan f ( state : 'State ) ( input : AsyncSeq < 'T >) =
290290 scanAsync ( fun st v -> f st v |> async.Return) state input
291291
292292 let map f ( input : AsyncSeq < 'T >) =
@@ -649,7 +649,14 @@ module AsyncSeq =
649649
650650 let distinctUntilChanged ( s : AsyncSeq < 'T >) : AsyncSeq < 'T > =
651651 distinctUntilChangedWith ((=)) s
652-
652+
653+ let getIterator ( s : AsyncSeq < 'T >) =
654+ let curr = ref s
655+ fun () ->
656+ async { let! v = curr.Value
657+ match v with
658+ | Nil -> return None
659+ | Cons ( v, t) -> curr := t ; return Some v }
653660
654661
655662
Original file line number Diff line number Diff line change @@ -303,7 +303,8 @@ module AsyncSeq =
303303 /// Returns an async sequence which contains no contiguous duplicate elements.
304304 val distinctUntilChanged : s : AsyncSeq < 'T > -> AsyncSeq < 'T > when 'T : equality
305305
306-
306+ /// Get a function that may be usesd as an async iterator for the sequence. This functionality may be replaced in later versions of this library.
307+ val getIterator : s : AsyncSeq < 'T > -> ( unit -> Async < 'T option >)
307308
308309/// An automatically - opened module tht contains the `asyncSeq` builder and an extension method
309310[< AutoOpen >]
Original file line number Diff line number Diff line change @@ -365,3 +365,21 @@ let ``AsyncSeq.while should allow do at end``() =
365365 do ! Async.Sleep 10
366366 }
367367 Assert.True( true )
368+
369+ [<Test>]
370+ let ``AsyncSeq.getIterator should work`` () =
371+ let s1 = [ 1 .. 2 ] |> AsyncSeq.ofSeq
372+ let i = AsyncSeq.getIterator s1
373+ match i() |> Async.RunSynchronously with
374+ | None -> Assert.Fail( " expected Some" )
375+ | Some v ->
376+ Assert.AreEqual( v, 1 )
377+ match i() |> Async.RunSynchronously with
378+ | None -> Assert.Fail( " expected Some" )
379+ | Some v ->
380+ Assert.AreEqual( v, 2 )
381+ match i() |> Async.RunSynchronously with
382+ | None -> ()
383+ | Some _ -> Assert.Fail( " expected None" )
384+
385+
You can’t perform that action at this time.
0 commit comments