我有这个问题:
Couldn't match expected type ‘case-insensitive-1.2.0.5:Data.CaseInsensitive.Internal.CI
Text’
with actual type ‘Text’
In the first argument of ‘named’, namely ‘n’
,因为:
Prelude Text.XML.Lens> :t named
named
:: Applicative f =>
case-insensitive-1.2.0.5:Data.CaseInsensitive.Internal.CI
Data.Text.Internal.Text
-> (Element -> f Element) -> Element -> f Element
我的代码导入Data.Text
并依赖OverloadedStrings
。我应该采取哪些措施来解决这样的问题?什么是短期和长期修复?
答案 0 :(得分:1)
感谢评论者,因为我能够找出我遇到这个问题的原因。
简答:密切注意类型并确保您理解它们(阅读错误消息中显示的任何模块的文档)。
长答案:
请注意,该类型包含空格,GHC
可能会将其分解为多行。 CI.Text
表示与CI Text
不同的内容。
‘case-insensitive-1.2.0.5:Data.CaseInsensitive.Internal.CI
Text’
Text
此处不是重新导出的内部Text
的类型同义词(库中的常见做法)。 CI
是一个类型构造函数,您无法导入它(出于某种原因 - 您必须停止并阅读您触摸的任何内容的文档)。您将理解为什么可以导入CI
类型和smart-constructors
而不是mk
。