arrow-fx
arrow-fx copied to clipboard
MonadIO/MonadBaseControl
Taken from: http://www.parsonsmatt.org/2017/11/21/monadbasecontrol_in_five_minutes.html
Not really a priority, as its main use case is IO transformations, and we don't know how widespread our IO will be.
Stretch goal: MonadBracket
for resource management https://www.fpcomplete.com/blog/2017/02/monadmask-vs-monadbracket
What exactly is needed for these two? Is it just a typeclass with a method each and instances for IO, mtl and the reactor/rx2 types? Because this would be quite useful in mtl style programs which use typeclasses and thus a polymorphic monad-stack . Currently you can do side-effects and almost all of IO
in there by using MonadDefer
and above, but you can't really interop with IO
nicely.
MonadBaseControl
exists based on the core idea that every effect/stream/concurrency system in Haskell should boil down to IO as the final runner. Our primitive could be suspend
, except that it doesn't have cancellation baked so we have to stick to IO
for now.
It's a thin wrapper over each framework that exists or we've written a version of in snippets here and there. This formalises it as a typeclass.
Yes I agree suspend makes a good marker, but as you said it does not have the same capabilities, so I'd like to have some sort of MonadIO
so that existing methods returning IO
can be included in mtl style monad-stacks.
Yeah, both is good.
I'll see if I can do something there then :) MonadIO
instances for mtl + IO and third party stuff should exists imo. There is also probably an easy implementation using the concurrent instances of those types, but we'll see :D