我正在使用http://hackage.haskell.org/package/dataenc-0.14.0.5/docs/Codec-Binary-Base64.html#v:encode,我发现这非常慢:
import qualified Codec.Binary.Base64 as C
import System.Environment
main = do
[arg] <- getArgs
print $ length $ C.encode $ replicate (read arg) 80
Run Code Online (Sandbox Code Playgroud)
参数10 ^ 5的运行时间:0.5 s,2 * 10 ^ 5:3.4 s,3 * 10 ^ 5:9.4 s。但是这样的事情应该线性运行吗?
当我寻找问题的原因时-是否有解决方法(其他库)?
PS:这行代码https://github.com/magthe/dataenc/blob/master/src/Codec/Binary/Base64.hs#L77看起来非常有问题(即二次):
doEnc acc (o1:o2:o3:os) = doEnc (acc ++ enc3 [o1, o2, o3]) os
doEnc acc os = EPart acc (eI os)
Run Code Online (Sandbox Code Playgroud)
果然,使用简单的代码
encode ws = case ws of
[] -> []
o1:ws2 -> case ws2 of
[] …Run Code Online (Sandbox Code Playgroud) 我正在使用xmonad(配置最少main = xmonad gnomeConfig{ modMask = mod4Mask, terminal = "gnome-terminal" }),我的计算机有两个显示器,我正在使用xinerama.
这很有效,但是当我将窗口推向屏幕(shift-mod-N)或将焦点移动到屏幕(mod-N)时,我常常对xmonad屏幕到监视器的映射感到惊讶.
此外,配合面板在虚拟屏幕符号上显示窗口符号 - 但有些东西不正确(这些虚拟屏幕似乎有双倍宽度,我猜因为它是一个X屏幕)
什么是正确的心理模型?
(是否有一个魔术键显示当前(聚焦)窗口的屏幕号?)
注意(由以下答案建议):在xmonad术语中,窗口位于工作空间,工作空间映射到(物理)屏幕.
我正在尝试使用optparse-applicative.如何访问不是选项的参数?(从prog --foo --bar=42 baz,我想得到["baz"])
所有"高级"函数https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/Options-Applicative-Extra.html
返回a我想要的地方(a,[String]).
有一些低级函数https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/Options-Applicative-Common.html#v:runParser但我不能直接调用它因为它的类型.事实上,我确实希望重新使用https://hackage.haskell.org/package/optparse-applicative-0.11.0.2/docs/src/Options-Applicative-Extra.html#execParser中的所有管道.
The "Automata View" in iSpin (v. 1.1.4) shows .. exactly what? It seems it is just a graph of the control flow of one process.
How would I get the full state space of the system?
例如,在Ben-Ari:自旋模型检查器的原理中,我想要图4.1。或在Overview中,我想要图1。
在下面的最后一行中,我想实例化一个多态函数并将其作为参数传递.
function id<T> (x:T) { return x; }
console.log ( id<number>(0) )
console.log ( id< (x:number)=>number > (id) (0) )
console.log ( id< (x:number)=>number > (id<number> ) (0) )
Run Code Online (Sandbox Code Playgroud)
我正进入(状态 error TS1005: '(' expected.
所以我似乎只有在调用函数时才能实例化类型参数.真?
离开实例化(倒数第二行)就行了.
作为参考,这适用于C#(注意:) id<int>:
using System;
class P {
static T id<T> (T x) { return x; }
public static void Main (string [] argv) {
Console.WriteLine (id<Func<int,int>> (id<int>) (0));
}
}
Run Code Online (Sandbox Code Playgroud)
好吧,我想这在TypeScript中是不可能的.标准 https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#4-expressions说"TypeScript使用以下结构扩充JavaScript表达式:...在函数调用中键入参数......"这显然意味着"仅在函数调用中键入参数".
我对此的语义感到惊讶(下面的第三个表达式).从这里开始:
Prelude> let (a,b) = (0,0) in (a,b)
(0,0)
Run Code Online (Sandbox Code Playgroud)
没关系.现在添加一个后卫,它仍然很好:
Prelude> let (a,b) | True = (0,0) in (a,b)
(0,0)
Run Code Online (Sandbox Code Playgroud)
现在改变警卫,并感到惊讶:
Prelude> let (a,b) | a == b = (0,0) in (a,b)
(^CInterrupted.
Run Code Online (Sandbox Code Playgroud)
怎么会? - 这有效:
Prelude> case (0,0) of (a,b) | a == b -> (a,b)
(0,0)
Run Code Online (Sandbox Code Playgroud) 我知道我可以输入端口号,config/settings.yml但在运行时它们似乎被忽略了yesod devel.
我有一个使用http-client https://www.stackage.org/haddock/lts-9.0/http-client-0.5.7.0/Network-HTTP-Client.html#v:httpLbs的yesod应用程序。我在打电话
resp <- httpLbs req man
Run Code Online (Sandbox Code Playgroud)
在Handler (Response BSL.ByteString) 单子里面。
我得到这个(在应用程序的日志中)
6/Aug/2017:15:14:17 +0200 [Error#yesod-core] HttpExceptionRequest Request { ...
Run Code Online (Sandbox Code Playgroud)
(下一行代码永远不会执行)
相反,我想捕获异常,并在我的代码中对其进行处理。怎么样?