Hopac/Hopac

Hopac Stream.groupBy deadlock

jokingbear opened this issue · 2 comments

Hopac 0.3.23
.NET 4.6

The following code seems to hang in F# interactive

let tmp = [ 0; 0; 0; 1; 1; 1; 2; 2; 2; 3; 3; 3 ]

let a = 
    tmp
    |> Stream.ofSeq
    |> Stream.groupByJob (fun k _ s -> Stream.count s |> Job.map (fun s -> k, s)) (Job.result)
    |> Stream.toSeq
    |> run

Yes, the example as written deadlocks. The reason is that Stream.count s |> ... is run immediately by groupByJob to get the value to be put into the result stream. Try the following instead:

tmp
|> Stream.ofSeq
|> Stream.groupByFun (fun k _ s -> Stream.count s |> Job.map (fun s -> k, s)) id
|> Stream.toSeq
>>= Job.seqCollect
|> run

it works, tks a lot