Haskell无法加载模块的接口

时间:2018-03-07 21:24:32

标签: haskell visual-studio-code cabal

你好我正在尝试在另一个模块中使用一个模块,但它似乎只是赢了工作。我尝试更新cabal文件,堆栈,我重新安装了平台,ghc和所有东西,它只是赢了'让它导入模块。我尝试在cabal文件中添加其他模块和家庭模块部分..没有效果。可能是什么问题?

模块:

module Test where


    test::IO()
    test=do
        elem<-getLine
        print elem


module Main where

import Test

main :: IO ()
main = do
  putStrLn "hello world"

Cabal-build呈现此错误:

$ cabal build

Resolving dependencies...
Configuring console-0.1.0.0...
Warning: To use the 'default-language' field the package needs to specify at
least 'cabal-version: >= 1.10'.
Preprocessing executable 'console' for console-0.1.0.0..
Building executable 'console' for console-0.1.0.0..

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: Test

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: Test

当我使用Stack构建时,我得到了这个错误:

C:\<path>\Main.hs:4:1: error:
    Failed to load interface for `Test'
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.
H>>= :module + *Main

Cabal文件:

 name:                console
version:             0.1.0.0
-- synopsis:
-- description:
homepage:            https://github.com/githubuser/console#readme
license:             BSD3
license-file:        LICENSE
author:              Bercovici Adrian Simon
maintainer:          example@example.com
copyright:           2018 Bercovici Adrian Simon
category:            Web
build-type:          Simple
cabal-version:       >=1.2
extra-source-files:  README.md


Executable console
  hs-source-dirs:      src
  main-is:             Main.hs
  default-language:    Haskell2010

  build-depends:       base                  >= 4.7    && < 5
  other-modules:       Test

1 个答案:

答案 0 :(得分:2)

other-modules:指令必须在Executable console节内。