gpt4 book ai didi

Haskell:如何解决可能的版本冲突?

转载 作者:行者123 更新时间:2023-12-04 05:35:47 27 4
gpt4 key购买 nike

我可能在依赖问题上遇到了一些麻烦,但并不完全确定。这是我的问题。我正在使用 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 中的一个键/值,键是 Label , 定义为 Text 的同义词, 值为 Value , 与 String作为其众多构造函数之一(即,这不是 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 依赖 hell ”。

最佳答案

在大多数情况下,您可以使用 cabal-dev 避免依赖 hell 。并在您的 .cabal 中指定软件包版本文件。

关于Haskell:如何解决可能的版本冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11957974/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com