更新时间:2022-12-13 11:43:40
根据所使用的工具,有不同的处理方法.
Depending on the tool one uses there are different ways to go about it.
如果使用了 stack
:
If stack
is used:
按照此问题接受的答案在这里允许我通过 stack build
将 pandoc-types
作为本地依赖项来编译代码.
Following the accepted answer in this question here allows me to compile the code via stack build
with pandoc-types
as a local dependency.
如果使用 cabal
:
If cabal
is used:
与上述解决方案一样,需要将本地依赖项添加到存储库的根文件夹中.此外,应将对依赖项 cabal
文件的引用添加到 packages:
部分中的 cabal.project
文件中,如下所示(这告诉cabal:还要编译此文件夹的内容):
As with the solution above one needs to add the local dependency into the root folder of the repo. Furthermore one should add a reference to the dependencies cabal
file to the cabal.project
file in the packages:
section as follows (which tells cabal to also compile the contents of this folder):
packages: pandoc-types/pandoc-types.cabal pandoc.cabal
package pandoc
flags: +embed_data_files -trypandoc
ghc-options: -j +RTS -A64m -RTS
source-repository-package
type: git
location: https://github.com/jgm/citeproc
tag: 0.1.0.1
<项目名称> .cabal
中的依赖项也需要删除版本限制.因此,文件已更改为:
Also the dependencies in the <projectname>.cabal
need the version restrictions removed. So the file is changed from this:
library
build-depends: pandoc-types >= 1.22 && < 1.23
...对此:
library
build-depends: pandoc-types
现在,我的代码使用 cabal build
进行编译.
Now my code compiles with cabal build
.
但是,我的问题仍然存在.当遵循这两种方法时,VSCode中的Haskell扩展仍无法正确自动完成.使用 stack
方法会给出警告,例如 do-notation语句丢弃了类型为...
的结果,并且出现了诸如 Cannot推断出...之类的错误,这些错误是由使用引起的的...
.实际上,第一个警告应该已经用 pandoc.cabal
中的 ghc-options
中的 -fno-warn-unused-do-bind
标志取消了>文件(假设这是扩展名读取的内容,以打印警告/错误).因此,我不知道是什么原因导致了这些错误.在构建过程中从Hackage下载回购库时,它们不存在.关于这个问题,我可能需要在堆栈溢出问题上再问一个问题.
However one part of my problem remains. When following both approaches the Haskell extension in VSCode still does not properly autocomplete. Using the stack
approach gives warnings like A do-notation statement discarded a result of type ...
and errors like Could not deduce ... arising from a use of ...
. The first warning should actually already be suppressed with the -fno-warn-unused-do-bind
flag in ghc-options
within the pandoc.cabal
file (assuming this is what the extension reads in order to print warnings/errors). So I don't know what is responsible for these errors. They are not present when the repo was downloaded from Hackage during the build process. I will probably need to ask another question on stack overflow regarding this issue.
无论如何,由于标题中的问题得到了回答,我希望这会在将来的某个时候对某人有所帮助.
Anyway since the question in headline is answered, I hope this helps someone at some point in the future.