ghci:模块"main:Main"在多个文件中定义-在新的小型堆栈init ghci包中 [英] ghci: module ‘main:Main’ is defined in multiple files - in new small stack init build ghci package
问题描述
我尝试使用vscode设置基于 stack
的Haskell IDE,并从使用 stack init
创建的小项目开始,然后在 src <中添加第二个模块./code>,并在
package.yaml
中添加了一些依赖项.它可以正常运行,但是当我启动 stack ghci
时,我会发出警告:
警告:多个文件使用相同的模块名称:*在以下路径中找到Paths_primo*/home/frank/Workspace11/primo/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/autogen/Paths_primo.hs(primo:lib)*/home/frank/Workspace11/primo/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/primo-exe/autogen/Paths_primo.hs(primo:exe:primo-exe)* * * * * * * * *GHCi版本8.10.4:https://www.haskell.org/ghc/:?求助[1 of 3]编译库(/home/frank/Workspace11/primo/src/Lib.hs,已解释)[2 of 3]编译YamlRead(/home/frank/Workspace11/primo/src/YamlRead.hs,已解释)[3之3]编译Main(/home/frank/Workspace11/primo/app/Main.hs,已解释)好了,加载了三个模块.
似乎与 autogen
和 Paths_primo
( primo
是软件包的名称)相混淆.我在做什么错了?
cabal
文件和 stack-work
目录是正确的.什么是 stack.yaml
和'stack.yaml.lock`?这似乎是在堆栈问题#5439 ,其根本原因是 hpack问题#303 .消除警告的一种解决方法是,通过在 package中的以下部分中添加以下内容,以禁用
: primo-exe
可执行文件的 Paths _
模块的生成.yaml
何时:-条件:假其他模块:Paths_primo
I try to setup a stack
based Haskell IDE with vscode and start with a small project created with stack init
and then added a second module in src
and added some dependencies in package.yaml
. It builds ok but when I start stack ghci
I have warnings:
Warning: Multiple files use the same module name:
* Paths_primo found at the following paths
* /home/frank/Workspace11/primo/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/autogen/Paths_primo.hs (primo:lib)
* /home/frank/Workspace11/primo/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/primo-exe/autogen/Paths_primo.hs (primo:exe:primo-exe)
* * * * * * * *
GHCi, version 8.10.4: https://www.haskell.org/ghc/ :? for help
[1 of 3] Compiling Lib ( /home/frank/Workspace11/primo/src/Lib.hs, interpreted )
[2 of 3] Compiling YamlRead ( /home/frank/Workspace11/primo/src/YamlRead.hs, interpreted )
[3 of 3] Compiling Main ( /home/frank/Workspace11/primo/app/Main.hs, interpreted )
Ok, three modules loaded.
There seems to be a confusion with autogen
and with Paths_primo
(primo
is the name of the package). What am I doing wrong?
General question: what is the correct way to clean a stack project to "start over" after some experimentation? Is is correct to delete the cabal
file and the stack-work
directory. Waht is with stack.yaml
and 'stack.yaml.lock`?
This appears to be a harmless warning reported at Stack issue #5439, whose underlying cause is hpack issue #303. A workaround to get rid of the warning is disabling the generation of the Paths_
module for your primo-exe
executable, by adding the following to its section in package.yaml
:
when:
- condition: false
other-modules: Paths_primo
这篇关于ghci:模块"main:Main"在多个文件中定义-在新的小型堆栈init ghci包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!