fpco / unliftio

The MonadUnliftIO typeclass for unlifting monads to IO
Other
151 stars 51 forks source link

Made 'withRunInIO' fully polymorphic #12

Closed effectfully closed 6 years ago

effectfully commented 6 years ago

withRunInIO was

withRunInIO :: MonadUnliftIO m => ((m a -> IO a) -> IO b) -> m b

and now it's

withRunInIO :: MonadUnliftIO m => ((forall a. m a -> IO a) -> IO b) -> m b

I also replaced withUnliftIO by withRunInIO everywhere in the codebase. Docs are updated accordingly, but please verify. I think it should be mentioned somewhere in the library that withUnliftIO now has quite a little number of uses (basically, if you want to put a UnliftIO m into some data type) and withRunInIO is a preferable function.

snoyberg commented 6 years ago

I think it should be mentioned somewhere in the library that withUnliftIO now has quite a little number of uses

I'm on board with that, do you want to include that note in the Haddocks for withUnliftIO itself?

effectfully commented 6 years ago

Done.

Personally, I think building the library around withRunInIO would make it easier to comprehend and there also won't be any hacky newtypes lying around which I think is a benefit. askUnliftIO can of course be implemented in terms of withRunInIO. What do you think?

In any case it's a great library: simple and useful. I'm currently in the pass-environments-explicitly camp, but I might reconsider this position in future, because now there is a sensible alternative. Thanks for this.

snoyberg commented 6 years ago

You mean moving it into the type class itself as a method, providing default implementations for both methods, and using MINIMAL to ensure one of them gets an instance? That sounds pretty good to me.

On Mon, Jan 1, 2018, 8:41 PM effectfully notifications@github.com wrote:

Done.

Personally, I think building the library around withRunInIO would make it easier to comprehend and there also won't be any hacky newtypes lying around which I think is a benefit. askUnliftIO can of course be implemented in terms of withRunInIO. What do you think?

In any case it's a great library: simple and useful. I'm currently in the pass-environments-explicitly camp, but I might reconsider this position in future, because now there is a sensible alternative.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/fpco/unliftio/pull/12#issuecomment-354668694, or mute the thread https://github.com/notifications/unsubscribe-auth/AADBBxHGI2iIdJNDthwuQveU-7FL0KbMks5tGSblgaJpZM4RQHzj .

effectfully commented 6 years ago

This discussion is irrelevant here, so I opened an issue.

Please say if there is something else that should be fixed in the pull request.

snoyberg commented 6 years ago

Thanks!