simonmar / async

Run IO operations asynchronously and wait for their results
BSD 3-Clause "New" or "Revised" License
322 stars 65 forks source link

Remove empty list error states in `waitAny*` functions #154

Open 414owen opened 1 year ago

414owen commented 1 year ago

I was debugging a thread blocked indefinitely on STM Transaction error recently, which ended up being caused by calling waitAnyCancel with an empty list.

More recent versions of async throw custom errors when this family of functions is passed an empty list.

I was wondering if, instead of throwing an error when passed empty lists, it would be better for these functions to take a Data.List.NonEmpty, which is in base?

simonmar commented 1 year ago

It would be a breaking change, which is unfortunate, and all call sites would have to be updated. So while it would indeed have been a better choice originally, I'm not sure whether it's worth changing it now.