我对 Haskell 非常陌生,我正在尝试将图形包光泽添加到我的堆栈项目中,但在执行 stack build
时遇到问题。
我已经按如下方式创建了我的堆栈项目:
LICENSE package.yaml stack.yaml
README.md package.yaml~ stack.yaml.lock
Setup.hs project39.cabal stack.yaml~
TAGS project39.cabal~ test
并按如下方式编辑 stack.yaml
和 cabal 文件:
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
# - gloss-1.13.2.1
executable project39-exe
main-is: Main.hs
other-modules:
Paths_project39
hs-source-dirs:
app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, project39
, gloss
default-language: Haskell2010
在 src
文件 Lib.hs 中,我添加了一个 Import Graphics.Gloss
来测试它是否有效:
module Lib
( someFunc
) where
import Graphics.Gloss
但是当我执行 stack build
时,我收到以下错误:
Could not load module ‘Graphics.Gloss’
It is a member of the hidden package ‘gloss-1.13.2.1’.
Perhaps you need to add ‘gloss’ to the build-depends in your .cabal file.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
4 | import Graphics.Gloss
| ^^^^^^^^^^^^^^^^^^^^^
我不确定这里的问题是什么以及如何解决。
答案 0 :(得分:0)
您的 package.yaml 中有一个单独的 library
节。您需要在那里添加 gloss
依赖项。