Skip to content

Commit 73e21d3

Browse files
banacornwz1000
authored andcommitted
Fix deriving instance of MonadUnliftIO
I'm getting trouble from MonadUnliftIO when building the project using stack src/Language/LSP/Server/Core.hs:75:63: error: • Couldn't match representation of type ‘m (UnliftIO (LspT config m))’ with that of ‘m (UnliftIO (ReaderT (LanguageContextEnv config) m))’ arising from the coercion of the method ‘askUnliftIO’ from type ‘ReaderT (LanguageContextEnv config) m (UnliftIO (ReaderT (LanguageContextEnv config) m))’ to type ‘LspT config m (UnliftIO (LspT config 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 (LspT config m)) | 75 | deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, MonadUnliftIO, MonadFix) | ^^^^^^^^^^^^^
1 parent 1b35565 commit 73e21d3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Language/LSP/Server/Core.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ import Control.Monad.Trans.Identity
7272
-- ---------------------------------------------------------------------
7373

7474
newtype LspT config m a = LspT { unLspT :: ReaderT (LanguageContextEnv config) m a }
75-
deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, MonadUnliftIO, MonadFix)
75+
deriving (Functor, Applicative, Monad, MonadIO, MonadTrans, MonadFix)
76+
77+
-- Manually deriving LspT as an instance of MonadUnliftIO
78+
instance MonadUnliftIO m => MonadUnliftIO (LspT config m) where
79+
withRunInIO inner =
80+
LspT $
81+
ReaderT $ \config ->
82+
withRunInIO $ \run ->
83+
inner (run . flip runReaderT config . unLspT)
7684

7785
runLspT :: LanguageContextEnv config -> LspT config m a -> m a
7886
runLspT env = flip runReaderT env . unLspT

0 commit comments

Comments
 (0)