当前有两个带有堆栈和 cabal 文件的项目(我使用堆栈来构建),一个是名为 test 的 exe,另一个是名为 testlib 的库。我想在测试项目中使用 testlib,我该怎么做才能让堆栈知道 testlib 是一个自定义库以及如何找到它?
-- projects/test/test.yaml
-- projects/testlib/testlib.yaml
Run Code Online (Sandbox Code Playgroud) 所以,我的package.yaml包含- hint包。
然后我尝试stack build我的项目。日志:
Configuring hint-0.7.0...
Preprocessing library for hint-0.7.0..
Building library for hint-0.7.0..
[ 1 of 18] Compiling Control.Monad.Ghc ( src/Control/Monad/Ghc.hs, .stack-wor$
[ 2 of 18] Compiling Hint.CompatPlatform ( src/Hint/CompatPlatform.hs, .stack$
[ 3 of 18] Compiling Hint.GHC ( src/Hint/GHC.hs, .stack-work/dist/x86$
[ 4 of 18] Compiling Hint.Extension ( src/Hint/Extension.hs, .stack-work/di$
[ 5 of 18] Compiling Hint.Base ( src/Hint/Base.hs, .stack-work/dist/x8$
[ 6 of 18] Compiling Hint.Conversions ( src/Hint/Conversions.hs, .stack-work/$
[ 7 of 18] Compiling Hint.Annotations …Run Code Online (Sandbox Code Playgroud) 我删除了 package.yml 文件以使用 .cabal 文件。现在我想尝试在 package.yml 中定义所有内容,并让 stack 自动生成 .cabal 文件。
但是当我手动将 .cabal 文件转换为 package.yml 并删除 .cabal 文件并运行时stack build,它显示了这个错误:
Stack looks for packages in the directories configured in the 'packages' variable defined in your stack.yaml
The current entry points to /Users/leo/zhangchiqing/hello/ but no .cabal file could be found there.
Run Code Online (Sandbox Code Playgroud)
如何从 package.yml 生成 .cabal 文件?
大家好,我正在尝试为 vscode 安装 ghc-mod,但我遇到了这个问题:
**$ stack install ghc-mod**
Populated index cache.
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for ghc-mod-5.8.0.0:
Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25 (latest matching version
is 1.24.2.0)
base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10 (latest matching
version is 4.9.1.0)
mcabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration has no specified version
(latest matching version is 0.7.3.0)
extra-1.6.8 from stack configuration …Run Code Online (Sandbox Code Playgroud) 在堆栈外运行美味测试时,我需要将字符串“失败日志”作为美味模式参数传递。
这在 bash 中非常简单:
PS C:\Pyrethrum> stack test --fast --ta "-p \"fail log\""
但尝试使用 Powershell 实现同样的目标让我抓狂:
PS C:\Pyrethrum> stack test --fast --ta "-p ""fail"" "
当没有空间时可以工作(运行测试)
PS C:\Pyrethrum> stack test --fast --ta "-p ""fail log"" "
解析目标时出错:找不到目录:日志
PS C:\Pyrethrum> stack test --fast --ta "-p `"fail log`""
尝试安装一个名为 log 的包
PS C:\Pyrethrum> stack test --fast --ta "-p \"fail log\""
选项 --ta:未终止的字符串:endOfInput
PS C:\Pyrethrum> stack test --fast --ta "-p /fail log/ "
...构建但模式需要引号
除虫菊-0.1.0.0:测试(套件:除虫菊测试,参数:-p /失败日志/)
选项-p:无法解析模式
让它在 Powershell 中运行的正确命令行是什么?
可能是一个愚蠢的问题:
Stack 文档提到添加package.yaml依赖项的正确位置,但我在项目目录中看到的只是一个stack.yaml文件;那么这个地方合适吗?
(我看到一个现有的问题询问这两个文件之间的冗余,但我什至根本没有看到该package.yaml文件!)
如果有帮助:
$ stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
Run Code Online (Sandbox Code Playgroud) 在尝试调试另一个问题时,我安装了一个似乎与我其他安装的一些软件包冲突的软件包。
\n\n我跑了
\n\n$ stack install regex-pcre-text\nregex-pcre-builtin-0.94.4.8.8.35: configure\nregex-tdfa-1.2.3.1: download\nregex-pcre-builtin-0.94.4.8.8.35: build\nregex-tdfa-1.2.3.1: configure\nregex-tdfa-1.2.3.1: build\nregex-pcre-builtin-0.94.4.8.8.35: copy/register\nregex-tdfa-1.2.3.1: copy/register\nregex-tdfa-text-1.0.0.3: download \nregex-tdfa-text-1.0.0.3: configure \nregex-tdfa-text-1.0.0.3: build \nregex-tdfa-text-1.0.0.3: copy/register\nregex-pcre-text-0.94.0.1: download \nregex-pcre-text-0.94.0.1: configure \nregex-pcre-text-0.94.0.1: build \nregex-pcre-text-0.94.0.1: copy/register\nCompleted 4 action(s). \nRun Code Online (Sandbox Code Playgroud)\n\n我不能再简单地导入
\n\nText.Regex.PCRE\nRun Code Online (Sandbox Code Playgroud)\n\n当我尝试时,我现在看到:
\n\n$ stack ghci\nPrelude> :set -XOverloadedStrings\nPrelude> import Text.Regex.PCRE\nRun Code Online (Sandbox Code Playgroud)\n\n产量
\n\n<no location info>: error:\n Ambiguous module name \xe2\x80\x98Text.Regex.PCRE\xe2\x80\x99:\n it was found in multiple packages:\n regex-pcre-0.94.4 regex-pcre-builtin-0.94.4.8.8.35\nRun Code Online (Sandbox Code Playgroud)\n\n我想将我的安装恢复到早期状态,以便我的计算机上Text.Regex.PCRE未经限定导入的代码继续像以前一样工作。
然而,看起来堆栈没有明确的卸载:
\n\n$ stack uninstall regex-pcre-text\n\nError: stack does …Run Code Online (Sandbox Code Playgroud) 我在 nix 中使用堆栈。我需要将环境变量作为数据库密码传递以在运行时连接到 Postgres。目前,我在 YAML 中启用了 nix 并自定义了自己.nix的密码以将密码放入.nix.
堆栈.yaml:
nix:
enable: true
pure: true
shell-file: shell.nix
Run Code Online (Sandbox Code Playgroud)
shell.nix:
{ghc}:
with (import <nixpkgs> {});
haskell.lib.buildStackProject {
inherit ghc;
name = "myenv";
buildInputs = [ postgresql_10 ];
PGPASSWORD = "pw";
}
Run Code Online (Sandbox Code Playgroud)
但是当我想将代码提交到 GitHub/Gitlab 并转到 CI/CD 管道时,显式输入密码.nix似乎不太好。我想知道有什么好的方法可以解决这个问题吗?
我正在按照https://jaspervdj.be/hakyll/tutorials/01-installation.html 中的 Hakyll 教程进行操作。
但似乎有些不对劲,我说不出是什么。当我运行 'stack init' 时,我收到此消息。
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- ./
Selecting the best among 16 snapshots...
* Partially matches lts-14.16
hakyll not found
- ourblog-com requires ==4.13.*
* Partially matches nightly-2019-11-25
hakyll not found
- ourblog-com requires ==4.13.*
* Partially matches lts-13.30
hakyll not found
- ourblog-com requires ==4.13.*
* Partially matches lts-12.26
hakyll version 4.12.4.0 found
- ourblog-com requires ==4.13.*
* Partially …Run Code Online (Sandbox Code Playgroud) 我正在尝试禁用 HLint 给我的一些警告。根据文档,我应该能够在我的文件顶部添加一个编译指示。所以我尝试了以下方法:
{-# HLINT ignore #-}
module Main where
Run Code Online (Sandbox Code Playgroud)
然而,这在运行时给了我一个错误stack build:
/Users/nene/somedir/src/Main.hs:1:1: warning: [-Wunrecognised-pragmas]
Unrecognised pragma
|
1 | {-# HLINT ignore #-}
| ^^^
Run Code Online (Sandbox Code Playgroud)
似乎 pragma 实际上在我的编辑器(带有“Haskell”扩展名的 VSCode)中有效,但在运行stack.
haskell ×10
haskell-stack ×10
cabal ×1
ghc-mod ×1
ghci ×1
hakyll ×1
hlint ×1
nix ×1
powershell ×1