我的 cabal 文件中定义了多个基准:
benchmark my-gauge-bench
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs:
bench/gauge
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wall -threaded -rtsopts -with-rtsopts=-N
build-depends:
QuickCheck
, base >=4.10 && <10
, bytestring
, gauge
default-language: Haskell2010
benchmark my-weigh-bench
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_pkg_core_gen
hs-source-dirs:
bench/weigh
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wall
build-depends:
QuickCheck
, base >=4.10 && <10
, bytestring
, weigh
Run Code Online (Sandbox Code Playgroud)
如何my-guage-bench使用 Stack 仅运行单个基准测试(如 )?
假设我有两个项目(project-a和project-b),我想将项目 a 包含到项目 b 中,而不将项目 a 上传到堆栈。我怎样才能在本地发布包并将其包含到project-b中?
# package.yaml for project-b
dependencies:
- base >= 4.7 && < 5
- project-a == 2.0.0.0
Run Code Online (Sandbox Code Playgroud) 我想使用Threepenny-gui开发一个新的 Haskell 项目。
\n我做的第一件事是通过创建一个堆栈项目$ stack new threepennydemo。从这里,这里,我做了以下事情:
#\xc2\xa0extra-deps: []\nRun Code Online (Sandbox Code Playgroud)\n到
\nextra-deps:\n - threepenny-gui-0.9.0.0\nRun Code Online (Sandbox Code Playgroud)\nlibrary\n exposed-modules:\n Lib\n other-modules:\n Paths_threepennydemo\n hs-source-dirs:\n src\n build-depends:\n base >=4.7 && <5\n default-language: Haskell2010\n\nexecutable threepennydemo-exe\n main-is: Main.hs\n other-modules:\n Paths_threepennydemo\n hs-source-dirs:\n app\n ghc-options: -threaded -rtsopts -with-rtsopts=-N\n build-depends:\n base >=4.7 && <5\n , threepennydemo\n default-language: Haskell2010\n\ntest-suite threepennydemo-test\n type: exitcode-stdio-1.0\n main-is: Spec.hs\n other-modules:\n Paths_threepennydemo\n hs-source-dirs:\n test\n ghc-options: …Run Code Online (Sandbox Code Playgroud) user$: stack install dictionaries
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for dictionaries-0.1.0.0:
binary-0.8.3.0 must match >=0.7.5 && <0.8 (latest applicable is 0.7.6.1)
time-1.6.0.1 must match >=1.5.0 && <1.6 (latest applicable is 1.5.0.1)
Run Code Online (Sandbox Code Playgroud)
使用上面的命令,我想dictionaries全局安装包.
我有什么选择?我计划stack unpack dictionaries,然后修改版本.但是,如何在全球范围内安装修改后的"本地"软件包?
这里的最佳做法是什么?
谢谢
通常,当向.cabal文件添加新的依赖项时,我指定了我依赖的新库的版本.但是stack使用一组策划的库,我想知道在.cabal文件中指定包版本是否有意义.我的猜测是指定lts版本stack.yaml就足够了.
我只想尝试Haskell d3js包.这是我试过的:
stack install d3js
Run Code Online (Sandbox Code Playgroud)
但它给出了错误:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for d3js-0.1.0.0:
base-4.9.1.0 must match >=4.6 && <4.7 (latest applicable is 4.6.0.1)
Run Code Online (Sandbox Code Playgroud)
我试过stack install base-4.6.0.1,它没有输出任何东西,但完成没有错误,但我尝试时仍然得到相同的错误stack install d3js.
我也尝试过使用cabal:
$ cabal install d3js
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: d3js-0.1.0.0 (user goal)
next goal: base (dependency of d3js-0.1.0.0)
rejecting: base-4.9.1.0/installed-4.9... (conflict: d3js => base>=4.6 && <4.7)
rejecting: base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0,
base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的haskell项目,只有可执行文件my-exec.它所做的就是打印"Hello,world!" 控制台.
我想创建脚本文件bin/setup.sh,它将运行我的可执行文件,也做一些echo
#!/usr/bin/env stack
-- stack exec bash
echo Echo printing
my-exec
Run Code Online (Sandbox Code Playgroud)
当我跑它时,我得到了
$ ./bin/setup.sh
./bin/setup.sh: line 2: --: command not found
Echo printing
Hello, world!
Run Code Online (Sandbox Code Playgroud)
我不明白这个文件的问题是什么,为什么它说--: command not found但仍然按预期工作.
我知道在这个简单的例子中我可以用更容易的形式编写它,但在我的实际情况中,我必须做10个非平凡的exec调用,并且不想stack exec多次重复.
那么我该怎么做才能摆脱这个错误呢?
是否有任何命令行开关可以stack告诉它下载所有相关软件包,而无需编译/安装任何内容?
如果我有一个简单的Haskell单行程序,那么ghc或ghci中的标志可以从命令行执行此操作吗?
我正在寻找类似的东西:
stack ghci -e 'putStrLn "hello world"'
Run Code Online (Sandbox Code Playgroud)
相近
$ R --quiet -e "cat('hello world')"
> cat('hello world')
hello world>
Run Code Online (Sandbox Code Playgroud)
要么
$ python -c "print('hello world')"
hello world
Run Code Online (Sandbox Code Playgroud)
(这个问题已经通过一个很好的答案得到了解决,但只是调试一下这个标志似乎/应该/在上面工作......)
奇怪的是,无法让看似支持的ghci -e人为我工作.测试它不仅仅是我的机器,我也在Ubuntu上运行它并遇到同样的问题:
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install --yes curl \
&& curl -sSL https://get.haskellstack.org/ | sh \
&& export HOME=/root/.local/bin:$HOME \
&& stack ghci -e 'putStrLn "hello world"'
Run Code Online (Sandbox Code Playgroud)
然后
$ docker build .
Run Code Online (Sandbox Code Playgroud)
产...
Stack has been installed to: /usr/local/bin/stack
WARNING: …Run Code Online (Sandbox Code Playgroud) 我试图在Haskell GHCi中声明一个函数为
fact :: Int -> Int
但我收到此错误- 错误: 在输入`->'上解析错误
我不明白为什么会这样。有人可以向我解释吗?谢谢。