“No instance for” trait that's already implemented

☆樱花仙子☆ 提交于 2019-12-24 09:59:16

问题


I'd like to use Servant's ClientM monad with finally:: MonadBaseControl IO m => m a -> m b -> m a, but am faced with error No instance for (MonadBaseControl IO ClientM).

Oddly, this exact instance appears to be defined already, be it from an internal module.

Do I need to explicitly import such instances somehow?


回答1:


It works fine if, as Daniel said, you import the module that defines the desired instance:

Prelude> import Control.Exception.Lifted
Prelude Control.Exception.Lifted> import Servant.Client
Prelude Control.Exception.Lifted Servant.Client> :set -XTypeApplications
Prelude Control.Exception.Lifted Servant.Client> :type finally @ ClientM
finally @ ClientM :: ClientM a -> ClientM b -> ClientM a


来源:https://stackoverflow.com/questions/50439760/no-instance-for-trait-thats-already-implemented

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!