Skip to content

Commit 205ce14

Browse files
committed
Add TaskSeq.cast and add documentation
1 parent 4963f0a commit 205ce14

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/FSharpy.TaskSeq/TaskSeq.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ module TaskSeq =
163163
// iter/map/collect functions
164164
//
165165

166+
let cast source : taskSeq<'U> = Internal.map (SimpleAction(fun x -> box x :?> 'U)) source
166167
let iter action source = Internal.iter (SimpleAction action) source
167168
let iteri action source = Internal.iter (CountableAction action) source
168169
let iterAsync action source = Internal.iter (AsyncSimpleAction action) source

src/FSharpy.TaskSeq/TaskSeq.fsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ module TaskSeq =
8787
/// Create a taskSeq of an array of async.
8888
val ofAsyncArray: source: Async<'T> array -> taskSeq<'T>
8989

90+
/// <summary>
91+
/// Casts each item in the <paramref name="source" /> sequence asynchyronously. This function does unconstrainted casting,
92+
/// by boxing the value and then casting it to the target type. For non-reference types, it is recommended
93+
/// to use <see cref="TaskSeq.map" /> instead.
94+
/// </summary>
95+
/// <exception cref="InvalidCastException">Thrown when the function is unable to cast an item to the target type.</exception>
96+
val cast: source: taskSeq<'T> -> taskSeq<'U>
97+
9098
/// Iterates over the taskSeq applying the action function to each item. This function is non-blocking
9199
/// exhausts the sequence as soon as the task is evaluated.
92100
val iter: action: ('T -> unit) -> source: taskSeq<'T> -> Task<unit>

0 commit comments

Comments
 (0)