regions icon indicating copy to clipboard operation
regions copied to clipboard

Is MonadBase IO better than MonadIO?

Open ocharles opened this issue 11 years ago • 6 comments

To me, MonadBase IO doesn't seem to add anything that MonadIO doesn't already do. However, the use of MonadBase IO means that my library now incurs a dependency on transformers-base, and potential my downstream users too. I may have misunderstood something, but if possible I think

onExit :: (region ~ RegionT s parent, MonadIO parent) => Finalizer -> region (FinalizerHandle region)

is preferable. If that doesn't work due to the type signature, then I'd just go with

onExit :: MonadIO parent => Finalizer -> RegionT s parent (FinalizerHandle (RegionT s parent))

(as it was before).

ocharles avatar Oct 29 '14 14:10 ocharles

Hi Ollie, I used MonadBase in regions because I used it in monad-control. I used MonadBase in monad-control because I wanted to generalize MonadBaseControl so that users can use it with the ST or STM base monads.

I don't think many (any) users are actually doing that though so it might not be that useful. However, switching monad-control to MonadIO at this point will break lots of code.

Although it might be possible to specialize regions to MonadIO. The specialization doesn't matter there because regions operates with an IO base monad anyway.

basvandijk avatar Oct 29 '14 15:10 basvandijk

Although it might be possible to specialize regions to MonadIO. The specialization doesn't matter there because regions operates with an IO base monad anyway.

Right, that was my main thought - we already have a well established class in a more prominant package that expresses exactly what you want. This change would only need to be done in regions, which (I assume) has a lot less users.

ocharles avatar Oct 29 '14 15:10 ocharles

Yes I think this makes sense. I don't have much time to work on this I'm afraid.

Care to give it a shot?

basvandijk avatar Oct 29 '14 16:10 basvandijk

Bas van Dijk [email protected] writes:

Yes I think this makes sense. I don't have much time to work on this I'm afraid.

Care to give it a shot?

Will do!

ocharles avatar Oct 29 '14 16:10 ocharles

Did anything end up happening about this?

expipiplus1 avatar Feb 23 '15 23:02 expipiplus1

I've fixed this in the RegionIOControl branch.

basvandijk avatar Feb 24 '15 11:02 basvandijk