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

时间:2017-03-01 11:53:03

标签: haskell cabal

在我的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

谢谢!

1 个答案:

答案 0 :(得分:2)

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