这是我当前的阴谋文件的简化版本:
cabal-version: 1.12
name: app
version: 0.1.0.0
author: CabalSaneDefault
maintainer: nobody
license: BSD3
license-file: LICENSE
build-type: Simple
extra-source-files:
ChangeLog.md
library
other-modules:
Paths_app
default-extensions: LambdaCase
build-depends:
HUnit
, QuickCheck
, aeson
, aeson-pretty
default-language: Haskell2010
executable app
main-is: Main.hs
other-modules:
AdminSettings
App
App404
AppAdmin
AppAdminGalleryImage
AppAdminSinglePage
hs-source-dirs:
src
default-extensions: LambdaCase
ghc-options: -Wall -O2
build-depends:
HUnit
, QuickCheck
, aeson
, aeson-pretty
default-language: Haskell2010
executable app-test
main-is: Test.hs
other-modules:
Paths_app
hs-source-dirs:
src-test
default-extensions: LambdaCase
ghc-options: -Wall -O2
build-depends:
HUnit
, QuickCheck
, aeson
, aeson-pretty
, app
default-language: Haskell2010
本质上是一个库app
,它同时定义了可执行文件app
和库。我定义了另一个app-test
可执行文件,并添加了app
作为依赖项。但是,在运行app-test
“可执行文件”(通过cabal v2-repl app-test
/ GHCi)时,如果我尝试导入模块,它将找不到它:
src-test/Test.hs:10:1: error:
Could not find module ‘Routes’
Perhaps you meant Rules (needs flag -package-key ghc-8.6.4)
Use -v to see a list of the files searched for.
|
10 | import Routes
| ^^^^^^^^^^^^^
这可能吗?
答案 0 :(得分:-1)
我正在使用hpack
生成阴谋文件,但未指定source-dirs
目录:
library:
ghc-options: -Wall
source-dirs: src
随后会生成以下内容的合适的阴谋:
library
exposed-modules:
AdminSettings
App
App404
AppAdmin
AppAdminGalleryImage
...
other-modules:
Paths_app
hs-source-dirs:
src
default-extensions: LambdaCase
ghc-options: -Wall
build-depends:
HUnit
, QuickCheck
, aeson
, aeson-pretty