Skip to content

Move askUnliftIO out of class #55

@akrmn

Description

@akrmn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions