【问题标题】:veryThick not in scope非常厚不在范围内
【发布时间】:2014-07-04 14:51:26
【问题描述】:

我正在尝试 Haskell 中的 Diagrams 模块。但我无法让 ghc 编译以下代码

{-# LANGUAGE NoMonomorphismRestriction #-}

import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine

main = mainWith (example :: Diagram B R2)

example = circle 1 # fc blue
                   # lw veryThick
                   # lc purple

问题是,veryThick 不在范围内。虽然文档here 说它在 Diagrams.TwoD.Attributes 中,但它不存在。 veryThick 是在哪里定义的,为什么 doc 有不一致的地方?

编辑:

我加了

import Diagrams.TwoD.Attributes

我得到了这个错误。

DiagramsTutorial.hs:5:8:
Could not find module `Diagrams.TwoD.Attributes'
Perhaps you meant Diagrams.Attributes (from diagrams-lib-1.1.0.7)
Use -v to see a list of the files searched for.

【问题讨论】:

  • 你为什么说它不存在? (我的意思是,您导入 Diagrams.TwoD.Attributes 对我来说并不明显;尽管我想您可能相信您导入的两个模块之一重新导出了它......?)另外,diagrams-lib 的版本你安装了吗?
  • 如该错误消息中所见,版本为 1.1.0.7
  • 在您指向的文档的左上角,它有diagrams-lib-1.2,因此它与您使用的版本不匹配。见hackage.haskell.org/package/diagrams-lib-1.1.0.7

标签: haskell


【解决方案1】:

您似乎安装了 Diagrams 版本 1.1.0.7。确保您正在阅读您正在使用的版本的黑线鳕,而不是最新版本。如果您想使用模块Diagrams.TwoD.Attribuites,请卸载当前版本并安装版本 1.2.0.1。否则,您将不得不像版本 1.1.0.7 doesn't include such a function 那样没有 veryThick 函数。

编辑:粗略地说,重新安装过程应该包括注销旧库(可选但强烈推荐)并安装新库:

ghc-pkg unregister diagrams-core --force
ghc-pkg unregister diagrams-lib
ghc-pkg unregister diagrams-svg
ghc-pkg unregister diagrams-contrib
ghc-pkg unregister diagrams
ghc-pkg list | grep diagrams
# ^^^ should not list any packages!  Unregister any remaining packages
cabal update
cabal install diagrams-lib-1.2.0.1
cabal install diagrams-svg

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多