gpt4 book ai didi

Haskell cabal 对文件和模块名称感到困惑

转载 作者:行者123 更新时间:2023-12-03 09:10:53 26 4
gpt4 key购买 nike

在我的 haskell 项目中,我有以下目录结构(缺少一些条目,但与此问题无关)

- quanthas
- quanthas.cabal
- src/
- QuantHas/
- Settings.hs

我的 Settings.hs 文件包含此模块头

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模块头是

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。谁能帮我理解发生了什么?

版本信息: 平台:运行 MacOS 10.12.3 的 Macbook Pro haskell :8.0.1 cabal :1.24.0.0

谢谢!

最佳答案

问题在于不同模块中的导入语句之一存在拼写错误。由于您使用的是不区分大小写的文件系统 (OS X),GHC 能够找到模块内容,但在检查模块头时发现它与导入语句不匹配并出错。

关于Haskell cabal 对文件和模块名称感到困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42531032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com