“无实例”已经实施的特质 [英] "No instance for" trait that's already implemented

查看:127
本文介绍了“无实例”已经实施的特质的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用仆人的 ClientM monad with finally :: MonadBaseControl IO m = > m a - > m b - > ma ,但遇到错误没有(MonadBaseControl IO ClientM)实例



奇怪的是,这个确切的实例似乎是已定义,可以从 internal

我需要以某种方式显式导入这些实例吗?


正如丹尼尔所说,如果你导入定义所需实例的模块,那么它工作得很好:



<$

p $ p> 前奏> 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> :最后输入@ ClientM
finally @ ClientM :: ClientM a - > ClientM b - > ClientM a


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?

解决方案

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

这篇关于“无实例”已经实施的特质的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆