如何使用内部Text模块处理编译错误?

时间:2016-01-08 17:45:01

标签: haskell text ghc

我有这个问题:

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。我应该采取哪些措施来解决这样的问题?什么是短期和长期修复?

1 个答案:

答案 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