arrow-kt / arrow-fx

Λrrow Fx is part of Λrrow, a functional companion to Kotlin's Standard Library
http://arrow-kt.io
Other
64 stars 15 forks source link

MonadIO/MonadBaseControl #27

Open pakoito opened 6 years ago

pakoito commented 6 years ago

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 commented 6 years ago

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

1Jajen1 commented 4 years ago

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.

pakoito commented 4 years ago

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.

1Jajen1 commented 4 years ago

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.

pakoito commented 4 years ago

Yeah, both is good.

1Jajen1 commented 4 years ago

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