basvandijk / regions

Provides the region monad for safely opening and working with scarce resources
Other
30 stars 7 forks source link

Is MonadBase IO better than MonadIO? #8

Open ocharles opened 10 years ago

ocharles commented 10 years ago

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).

basvandijk commented 10 years ago

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.

ocharles commented 10 years ago

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.

basvandijk commented 10 years ago

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?

ocharles commented 10 years ago

Bas van Dijk notifications@github.com 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!

expipiplus1 commented 9 years ago

Did anything end up happening about this?

basvandijk commented 9 years ago

I've fixed this in the RegionIOControl branch.