Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move askUnliftIO out of class #55

Closed
akrmn opened this issue Feb 27, 2020 · 4 comments
Closed

Move askUnliftIO out of class #55

akrmn opened this issue Feb 27, 2020 · 4 comments

Comments

@akrmn
Copy link

akrmn commented Feb 27, 2020

When defining monad transformers as newtypes over IdentityT or ReaderT r, I'd like to simply derive an instance for UnliftIO with the newtype strategy,

newtype Newtype m a = Newtype (m a) 
  deriving newtype (Functor, Applicative, Monad, MonadIO, MonadUnliftIO)

However, this currently fails with the error

    • Couldn't match representation of type ‘m (UnliftIO (Newtype m))’
                               with that of ‘m (UnliftIO m)’
        arising from the coercion of the method ‘askUnliftIO’
          from type ‘m (UnliftIO m)’
            to type ‘Newtype m (UnliftIO (Newtype m))’
      NB: We cannot know what roles the parameters to ‘m’ have;
        we must assume that the role is nominal
    • When deriving the instance for (MonadUnliftIO (Newtype m))

This could be avoided by moving the askUnliftIO method out of the class definition. This is pretty much the breaking part of #13.

@snoyberg
Copy link
Member

snoyberg commented Mar 1, 2020

Good call, it's about time. I'm testing a few other packages, and then I'll release.

@akrmn
Copy link
Author

akrmn commented Mar 1, 2020

Thanks a lot!

pnwamk pushed a commit to pnwamk/semmc that referenced this issue Mar 4, 2020
pnwamk pushed a commit to GaloisInc/semmc that referenced this issue Mar 4, 2020
danmatichuk added a commit to GaloisInc/semmc that referenced this issue Mar 11, 2020
askUnliftIO was moved due to fpco/unliftio#55
in version 0.2.0.0
mtth added a commit to mtth/tracing that referenced this issue Apr 5, 2020
The package pulls in many dependencies (some of which weren't already on
Stackage) and was only used for minor functionality.

Also temporarily add upper bound on unliftio-core due to
fpco/unliftio#55.
@evanrelf
Copy link
Contributor

evanrelf commented Apr 8, 2021

Now that askUnliftIO is no longer a method in the MonadUnliftIO class, would it be possible to remove or deprecate wrappedWithRunInIO? I wasn't aware you could just derive MonadUnliftIO for newtypes (and get a correct instance) because of the example for wrappedWithRunInIO saying you can't.

@snoyberg
Copy link
Member

snoyberg commented Apr 8, 2021

I'm OK with deprecating, but I think the more direct fix here is fixing the documentation, which is simply out of date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants