
[英]How to run a group of tests sequentially?
我有美味的测试看起来像:myTests :: [TestTree] myTests = [ testCase "1" $ do ... assertBool ... , testCase "2" $ do ... assertBool ... , testCase "3" $ do ...
[英]How to run a group of tests sequentially?
我有美味的测试看起来像:myTests :: [TestTree] myTests = [ testCase "1" $ do ... assertBool ... , testCase "2" $ do ... assertBool ... , testCase "3" $ do ...
[英]How do I get the parameters out of the Maybe wrapper correctly?
我想从 Maybe 包装器中获取 Maybe 参数包含一个或多个近似结果的包装器 试图获得价值 我收到这个错误 PS 我认为 parseInput 对于上下文很重要,所以事实证明 calculatePoints 也是必需的,所以我将它们包括在内 ...
[英]Manual performGC hugely reduces memory footprint
我的程序在 IO 中使用 GHC GhcMonad ,在IO中进行一些计算并在返回结果之前强制计算结果; 是这样的: 在暂停点,我可以看到进程使用了 30+ GB 的 RAM; 由于continueProcessingOutsideGhc本身也使用了一些 memory,这可能导致在continueP ...
[英]Is there a van Laarhoven optic based on the Monad typeclass?
据我了解,每个 van Laarhoven 光学类型都可以通过类型构造函数的约束来定义:type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t type Traversal s t ...
[英]"Extending" an interface to allow for optional usage of function in instances
我正在尝试将可选间距添加到生成的源代码中,源代码生成为多种语言,如 Python 和 Java。 我有一个抽象文件(非最终代码语言特定)我有一个 function 用于创建“if”控制语句。 它类似于: 这部分在这里不是太重要,除了在这个 function 的正文中有类似<+> sta ...
[英]How to test Monad instance for custom StateT?
我正在学习 Monad Transformers,其中一项练习要求为StateT实现 Monad 实例。 我想使用有效性package 测试我的实现是否符合 Monad 法则,这类似于checkers package。 问题是,我的Arbitrary实例无法编译。 我看到了这个问题,但它并没有完全 ...
[英]Why Haskell treats a stuck application of a type family as a valid type?
以这段代码片段为例(在各种评论和答案提到它之后,我将类型族更改为封闭式):-- a closed type family for which I won't define any instances type family EmptyTypeFamily t where -- 1. this t ...
[英]Haskell Yesod: Sending a Post Request On Image Click
我正在用 Yesod 在 Haskell 写一个简单的网站。 我有以下小村庄<ul id="gallery"> $forall file <- listOfFiles <form action=@{Charact ...
[英]Haskell Cabal: omitting version a big mistake
我在没有指定version:的*.cabal文件上运行cabal build ,它似乎混淆了 cabal。 当我放回版本规范时,我得到了 也就是说,通常yah.cabal文件会读取 并且cabal build在没有version的情况下提供了上面的内容,也许没有cabal-version - 不确定 ...
[英]Automatically detect whether a Haskell function is tail recursive
我目前正在为 Haskell 课程编写自动评分器。 对于“尾递归”部分,我需要一种方法来自动安全地检测给定的 Haskell function 是否为尾递归。 我搜索了现有工具,但找不到任何东西。 我假设必须有一种方法可以自动执行此操作,因为毕竟这是 Haskell 编译器为我们所做的。 该方法不必 ...
[英]Haskell Servant: How to deal with invalid Accept header (or ignore it completely)
我正在编写一个 webhook 端点(接收端)并且实际上无法控制请求中传入的Accept header。 它是这样的: 我试过Post '[JSON, HTML, PlainText] Text但它导致了406状态代码。 Accept ,由于* (可能应该是*/* )和q=.2 (可能应该是q= ...
[英]Why parallelizing this code yields almost no performance improvement on six core machine?
我正在使用 Simon Marlow 的书在 Haskell 中学习并行编程。 在有关并行化数独求解器的章节中,我决定使用回溯算法编写自己的求解器。 问题是当我尝试在 6 个内核中分配 6 个案例时几乎没有性能提升。 当我尝试用更多案例做示例时,我获得了更显着的性能提升,但仍远未达到理论上的最大值 ...
[英]Why in some cases some come works when pattern matching via case-of, but not via a let binding?
我试图了解单例。 作为练习,我为自定义List类型手动定义了一个SingKind实例:data List a = Nil | Cons a (List a) data SList :: List a -> Type where SNil :: SList 'Nil SCo ...
[英]How to handle following dependency conflict in Cabal?
当我尝试将scotty package 添加到我的多项目 cabal 文件时,出现以下依赖冲突。 我不太确定这是什么意思。 我该如何解决这种依赖冲突? ...
[英]Haskell: parallel do versus list comprehension
要使列表推导式并行运行, using parList rdeepseq很容易,但如果列表推导式是使用do表示法表示的呢? 例如,这段代码并行运行得很好。 但是用do表示法更容易阅读。 上面的部分,以 do 形式表达,并在更广泛的背景下变成: 但是不清楚如何让do表单并行运行。 有没有一种直接的方法可 ...
[英]How can I get an modulo of a calculation in Haskell?
我只是想获取当天的 Unixtime。 为此,我想得到当前时间的模数除以一天的时间跨度。 . 这是我当前的代码。 那么为什么我的代码不起作用? 它说“Variable not in scope: k”我也试着在“yourUnixTime”和等号之间放一个“k”,也没有用(还有更多我无法理解的错误 ...
[英]Converting quarters, dimes, and pennies to dollars and cents in Haskell
我正在尝试将 25 美分、10 美分和便士转换为美元和美分,但我似乎无法运行代码。 我试过这段代码: 它导致了这个错误: ...
[英]Why did HSL extension stop working on VS Code?
我正在使用 Windows 11。我一直在使用 Haskell 和 VS Code。 昨天它突然停止给我问题部分(一个在编译代码之前显示语法错误等的部分)。 我正在使用 Haskells 自己的扩展(ID:haskell.haskell)。 我不完全确定,但可能是 Haskell 语言服务器导致了 ...
[英]Haskell code: how to skip every other number in a list of primes
目标是获得一个跳过所有其他素数的素数列表。 一个例子是 primeskip 10 --> [2,5,11,17,23,31,41,47,59,67]。 我很确定我的 prime function 有效,但我在 skip 中做错了。 这是我的代码。 我试图乱用 filter 命令,但我不知道自己 ...
[英]No instance for (Random (IO a0)) arising from a use of `randomR' in Haskell
我正在尝试使用 randomR 生成一个随机数,但它显示了一个我没有得到的错误。 我的代码: 请让我知道解决方案 ...