使用stack,您可以指定-with-rtsopts如下package.yaml
ghc-options:
- -with-rtsopts=-N
Run Code Online (Sandbox Code Playgroud)
然而,尚不清楚如何同时表示多个 rtsopt。在此示例中,我在它们两边加上了双引号
ghc-options:
- -with-rtsopts="-N -I0 -qg"
Run Code Online (Sandbox Code Playgroud)
...但这不起作用...
Preprocessing library for uke-0.1.0.0..
Building library for uke-0.1.0.0..
Preprocessing executable 'uke-exe' for uke-0.1.0.0..
Building executable 'uke-exe' for uke-0.1.0.0..
ghc: unrecognised flag: -qg"
Run Code Online (Sandbox Code Playgroud)
-with-rtsopts转义多个值的正确方法是什么package.yaml?
我收到此错误:
Could not find module ‘Data.Binary’
It is a member of the hidden package ‘binary-0.7.5.0@binar_IvYoLp9H6Xy3zEH13MmZwd’.
Run Code Online (Sandbox Code Playgroud)
当我Data.Binary使用GHCi版本7.10.2 导入我的堆栈项目时.
奇怪的是,如果我执行GHCi,这不会出现stack exec ghci,并且我无法binary通过堆栈安装更新版本的包,它看起来:
D:\p>stack install binary
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'
D:\p>stack install binary-0.7.6.1
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the install command is functionally equivalent to 'build --copy-bins'
Error parsing targets: Specified target version …Run Code Online (Sandbox Code Playgroud) 在我的集团文件中,我具有以下构建依赖性:
build-depends: base >= 4.7 && < 5,
containers >= 0.5.10 && < 0.6
Run Code Online (Sandbox Code Playgroud)
当我尝试运行时stack build,出现以下错误:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for server-0.1.0.0:
containers-0.5.7.1 must match >=0.5.10 && <0.6 (latest applicable is 0.5.10.2)
Run Code Online (Sandbox Code Playgroud)
我遇到了这个问题,cabal我通过使用Cabals的沙箱解决了这个问题。我不知道如何通过查看--help文档,错误,堆栈文档和搜索来解决堆栈问题。如果不通过cabal文件,如何告诉堆栈我想要较新版本的容器?
我还尝试了跑步stack install containers-0.5.7.1,但没有达到我的预期。我在安装列表中看到一个容器。我注意到文档说堆栈默认情况下是沙盒,但是由于容器的依赖性,要构建这个简单的源文件非常麻烦。
我注意到此命令报告了旧版本的容器,而不是我想要的版本:
$ stack list-dependencies
array 0.5.1.1
base 4.9.1.0
containers 0.5.7.1
deepseq 1.4.2.0
ghc-prim 0.5.0.0
Run Code Online (Sandbox Code Playgroud) 当我学习一门新语言时,我要做的第一件事就是阅读快速傅里叶变换实现并尝试使其工作.这是一个我非常熟悉的算法 - 所以它帮助我理解语言是如何工作的.
目前,我正在阅读Roman Cheplyaka的这一实施.我现在非常密切地遵循算法,一切似乎都按预期工作,但是下面的一段代码为我抛出了一堆错误:(具体来说,该squareMap部分会抛出错误)
evalFourier coeffs pts = do
let
squares = nub $ u_sqr <$> pts -- values of x^2
(even_coeffs, odd_coeffs) = split coeffs
even_values <- evalFourier even_coeffs squares
odd_values <- evalFourier odd_coeffs squares
let
-- a mapping from x^2 to (A_e(x^2), A_o(x^2))
square_map =
Map.fromList
. zip squares
$ zip even_values odd_values
-- evaluate the polynomial at a single point
eval1 :: U -> Writer (Sum Int) (Complex a)
eval1 x = …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Haskell项目中包含特定版本的库.该库是住宿和早餐(用于martix操作),但我需要特定版本0.4.3修复了乘法实现的错误.
所以,我的stack.yaml看起来像这样:
flags: {}
extra-package-dbs: []
packages:
- .
extra-deps:
- bed-and-breakfast-0.4
- base-4.6.0.1
resolver: lts-12.8
Run Code Online (Sandbox Code Playgroud)
但是我在构建时遇到了这个错误:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for bed-and-breakfast-0.4:
base-4.11.1.0 from stack configuration does not match >=4.5 && <4.7 (latest matching version
is 4.6.0.1)
needed due to realworldhaskell-0.1.0.0 -> bed-and-breakfast-0.4
Some different approaches to resolving this:
* Set 'allow-newer: true' to ignore all version constraints and build anyway.
* Consider trying 'stack solver', which uses the …Run Code Online (Sandbox Code Playgroud) 我有一个游戏,用户与计算机,我想随机选择谁开始游戏.我有
a = getStdRandom $ randomR (0, 1)
Run Code Online (Sandbox Code Playgroud)
这得到一个随机数0或1.但它是一个IO Int,所以我不能有一个if语句将它与一个数字相比较
if a == 0 then userStarts else computerStarts
Run Code Online (Sandbox Code Playgroud)
我试图比较IO Int与IO Int和它不工作了,我也试着
我对Haskell很新,不知道如何处理这个问题.要求的代码详情:
randomNumber = getStdRandom $ randomR (0, length symbols - 5) -- this will be 0 or 1
randomNumber2 = getStdRandom $ randomR (0, length symbols - 5) -- according to
-- the solution I need another function returning IO int.
a = do
x <- randomNumber
randomNumber2 $ pureFunction x …Run Code Online (Sandbox Code Playgroud) random haskell functional-programming io-monad haskell-stack
我想定义数据类型Currency,它由其他三个数据类型组成。我有一个问题,Haskell无法将数据类型识别为货币的一部分,这破坏了一切。
我的想法是将不同的货币定义为它们自己的数据类型,然后将它们添加到“货币”类型,我尝试使用:
data Euro = MkEuro Integer Integer
data Dollar = MkDollar Integer Integer
data Yen = MkYen Integer
data Currency = Euro | Dollar | Yen
Run Code Online (Sandbox Code Playgroud)
如果要在任何函数中使用货币类型,则会得到以下错误消息的变体:
Couldn't match expected type `Currency' with actual type `Dollar'
Run Code Online (Sandbox Code Playgroud)
可悲的是,我必须使用货币类型,并且不能为所有三种货币创建不同的功能。