arrow-fx icon indicating copy to clipboard operation
arrow-fx copied to clipboard

MonadIO/MonadBaseControl

Open pakoito opened this issue 6 years ago • 6 comments

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.

pakoito avatar Nov 23 '17 13:11 pakoito

Stretch goal: MonadBracket for resource management https://www.fpcomplete.com/blog/2017/02/monadmask-vs-monadbracket

pakoito avatar Dec 12 '17 02:12 pakoito

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.

1Jajen1 avatar Jan 08 '20 23:01 1Jajen1

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.

pakoito avatar Jan 10 '20 20:01 pakoito

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.

1Jajen1 avatar Jan 10 '20 20:01 1Jajen1

Yeah, both is good.

pakoito avatar Jan 10 '20 21:01 pakoito

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

1Jajen1 avatar Jan 10 '20 21:01 1Jajen1