我正在尝试使用堆栈在Haskell中构建一个简单的程序。我使用创建了一个新项目,stack new
然后执行了一个stack setup
。模板构建良好。
我想尝试二进制文件解析,所以我导入了Data.ByteString
。我build-depends
在集团文件中看起来像这样:
build-depends: base >= 4.7 && < 5
, bytestring >= 0.10.6
, binary >= 0.7.5
stack ghci
现在可以正常工作,但stack build
仍然不快乐。有人可以告诉我我在这里做错了什么吗?
这是完整的错误消息:
test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
In-place registering test-0.1.0.0...
Preprocessing executable 'test-exe' for test-0.1.0.0...
haskell/test/app/Main.hs:4:18:
Could not find module ‘Data.ByteString’
It is a member of the hidden package ‘bytestring-0.10.6.0@bytes_6VWy06pWzJq9evDvK2d4w6’.
Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
haskell/test/app/Main.hs:5:8:
Could not find module ‘Data.Binary.Get’
It is a member of the hidden package ‘binary-0.7.5.0@binar_3uXFWMoAGBg0xKP9MHKRwi’.
Perhaps you need to add ‘binary’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
-- While building package test-0.1.0.0 using:
.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
这是我的app / Main.hs文件:
module Main where
import Lib
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word
main :: IO ()
main = do
putStrLn "f"
非常感谢您的帮助。
这可能是因为您添加bytestring
到build-depends
库的而不是可执行文件。避免需要针对不同的节重复这些依赖关系的一种方法是使用hpack作为程序包描述格式。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句