2

我可能在依赖问题上遇到了一些麻烦,但并不完全确定。这是我的问题。我正在使用 Data.Bson 库,并将一些 (Text, Text) 元组转换为 bson 字段,当我定义这个函数时:

typeMismatch :: (Text, Text) -> Field
typeMismatch tp = (fst tp) := (String (snd tp))

它抱怨:

Couldn't match expected type `Label' with actual type `Text'
Expected type: (Label, b0)
  Actual type: (Text, Text)

Field基本上只是 Bson 中的一个键/值,键是 a Label,定义为 的同义词Text,值是ValueString是其众多构造函数之一(即,这不是Prelude.String)。现在我尝试将第一个文本更改为标签:

typeMismatch :: (Label, Text) -> Field
typeMismatch tp = (fst tp) := (String (snd tp))

所以标签匹配,虽然这不是我想要的,我只是为了调查,但它仍然抱怨:

Couldn't match expected type `text-0.11.2.0:Data.Text.Internal.Text'
            with actual type `Text'
Expected type: (Label, text-0.11.2.0:Data.Text.Internal.Text)
  Actual type: (Label, Text)

看起来我有一些依赖问题或模块导入问题。但是我检查了我的库,似乎 bson 使用 text-0.11.2.0 而 data.text 也只是 text-0.11.2.0,所以一切都应该是一致的。

我该如何解决这个问题?提前致谢。

编辑:解决了。通过添加“-v”标志在编译时检查依赖关系。出于某种原因,还有 text-0.11.2.2 潜伏在那里。ghc-pkg 取消注册该包并编译。从现在开始,我需要开始学习如何避免“haskell 依赖地狱”。

4

2 回答 2

2

在大多数情况下,您可以通过在文件cabal-dev中指定包版本来避免依赖地狱。.cabal

于 2012-08-14T20:02:11.110 回答
1

https://github.com/Paczesiowa/hsenv is another option too. I find it to be a little more transparent than cabal-dev, and if you've used either rvm or virtualenv, you already know how to use make it work.

于 2012-08-15T15:31:21.293 回答