by eru · 5y ago · 0 comments
Trio's nurseries remind a little bit of IO in Haskell.
Forgetting all about Monads etc, you can re-interpret IO-typing in Haskell as the requirement to keep carry something like a 'nursery' around with your code. Parts of code that don't have access to such a 'nursery'-like object can't do IO. (And because it's Haskell, that access is also tracked in the types.)
https://hackage.haskell.org/package/async
The package description at the top of the link touches on the motivations which basically mirror this article.
I’ve personally never reached for the built in forkIO. withAsync or it’s helpers like mapConcurrently are always equally capable, easier to use, and with none of the foot guns.