Haskell cabal 对文件和模块名称感到困惑
Haskell cabal confused about file and module name
在我的 haskell 项目中,我有以下目录结构(有些条目丢失但与此问题无关)
- quanthas
- quanthas.cabal
- src/
- QuantHas/
- Settings.hs
我的 Settings.hs 文件包含这个模块 header
module QuantHas.Settings(module QuantHas.Settings) where
我的 cabal 文件如下所示
Name: QuantHas
Version: 0.0
Description:
QuantHas project is an attempt to port QuantLib to Haskell keeping the functional flavor of Haskell.
License: BSD3
License-file: LICENSE
Build-Type: Simple
Cabal-Version: >=1.10
Library
Build-Depends: base >= 3 && < 5, array >= 0.2
Exposed-modules: QuantHas.Time.Frequency
QuantHas.Time.TimeUnit
QuantHas.Time.Period
QuantHas.Time.Date
QuantHas.Time.DayCounter
QuantHas.Time.BusinessDayConvention
QuantHas.Time.Calendar
QuantHas.Time.Calendars.UnitedKingdom
QuantHas.Time.Schedule
QuantHas.Settings
QuantHas.Require
default-language: Haskell2010
hs-source-dirs: src
-- ghc-options: -Wall
test-suite QuantHas-tests
type: exitcode-stdio-1.0
hs-source-dirs: testsuite
main-is: Tests.hs
default-language: Haskell2010
当我执行
cabal install --enable-tests
我收到这条消息
src/Quanthas/Settings.hs:17:8: error:
File name does not match module name:
Saw: ‘QuantHas.Settings’
Expected: ‘Quanthas.Settings’
这似乎是错误的。然而,如果我们按照 cabal 的期望去做呢?所以 Settings.hs 模块 header 现在是
module Quanthas.Settings(module Quanthas.Settings) where
Cabal 现在说
src/QuantHas/Settings.hs:17:8: error:
File name does not match module name:
Saw: ‘Quanthas.Settings’
Expected: ‘QuantHas.Settings’
正是在这一点上,我放弃并转向 SO。任何人都可以帮助我了解发生了什么吗?
版本信息:
平台:Macbook Pro 运行 MacOS 10.12.3
Haskell:8.0.1
阴谋集团:1.24.0.0
谢谢!
问题是不同模块中的其中一个导入语句中存在拼写错误。由于您使用的是不区分大小写的文件系统 (OS X),GHC 能够找到模块内容,但在检查模块头时发现它与导入语句不匹配并出错。
在我的 haskell 项目中,我有以下目录结构(有些条目丢失但与此问题无关)
- quanthas
- quanthas.cabal
- src/
- QuantHas/
- Settings.hs
我的 Settings.hs 文件包含这个模块 header
module QuantHas.Settings(module QuantHas.Settings) where
我的 cabal 文件如下所示
Name: QuantHas
Version: 0.0
Description:
QuantHas project is an attempt to port QuantLib to Haskell keeping the functional flavor of Haskell.
License: BSD3
License-file: LICENSE
Build-Type: Simple
Cabal-Version: >=1.10
Library
Build-Depends: base >= 3 && < 5, array >= 0.2
Exposed-modules: QuantHas.Time.Frequency
QuantHas.Time.TimeUnit
QuantHas.Time.Period
QuantHas.Time.Date
QuantHas.Time.DayCounter
QuantHas.Time.BusinessDayConvention
QuantHas.Time.Calendar
QuantHas.Time.Calendars.UnitedKingdom
QuantHas.Time.Schedule
QuantHas.Settings
QuantHas.Require
default-language: Haskell2010
hs-source-dirs: src
-- ghc-options: -Wall
test-suite QuantHas-tests
type: exitcode-stdio-1.0
hs-source-dirs: testsuite
main-is: Tests.hs
default-language: Haskell2010
当我执行
cabal install --enable-tests
我收到这条消息
src/Quanthas/Settings.hs:17:8: error:
File name does not match module name:
Saw: ‘QuantHas.Settings’
Expected: ‘Quanthas.Settings’
这似乎是错误的。然而,如果我们按照 cabal 的期望去做呢?所以 Settings.hs 模块 header 现在是
module Quanthas.Settings(module Quanthas.Settings) where
Cabal 现在说
src/QuantHas/Settings.hs:17:8: error:
File name does not match module name:
Saw: ‘Quanthas.Settings’
Expected: ‘QuantHas.Settings’
正是在这一点上,我放弃并转向 SO。任何人都可以帮助我了解发生了什么吗?
版本信息: 平台:Macbook Pro 运行 MacOS 10.12.3 Haskell:8.0.1 阴谋集团:1.24.0.0
谢谢!
问题是不同模块中的其中一个导入语句中存在拼写错误。由于您使用的是不区分大小写的文件系统 (OS X),GHC 能够找到模块内容,但在检查模块头时发现它与导入语句不匹配并出错。