我想我理解PHOAS(参数高阶抽象语法),我看到我们如何打印表达式(参见http://www.reddit.com/r/haskell/comments/1mo59h/phoas_for_free_by_edward_kmett/ccbxzoo) .
但是 - 我没有看到如何为这样的表达式构建解析器,例如,接受"(lambda (a) a)"和构建(Haskell值对应)lam $ \ x -> x.(它应该使用Text.Parsec或类似的.)
我可以使用de-Bruijn索引构建一个生成lambda项的解析器,但它会有什么帮助呢?
我试图使用ghc-7.10(RC 2)并在许多情况下得到此消息,例如,
src/Text/Regex/XMLSchema/Generic/RegexParser.hs:439:5:
Non type-variable argument
in the constraint: Text.Parsec.Prim.Stream s m Char
(Use FlexibleContexts to permit this)
When checking that ‘prop’ has the inferred type
prop :: forall s u (m :: * -> *) (t :: * -> *).
(Foldable t, Text.Parsec.Prim.Stream s m Char) =>
Char -> t Char -> Text.Parsec.Prim.ParsecT s u m [Char]
In an equation for ‘isCategory'’:
isCategory'
= (foldr1 (<|>) . map (uncurry prop)
$ [('L', "ultmo"), ('M', "nce"), ('N', "dlo"), ....])
<?> …Run Code Online (Sandbox Code Playgroud) 什么是惯用的方式Double -> Float?
是uncurry encodeFloat . decodeFloat吗?
(我正在使用gloss,这需要Floats)
找到这些问题答案的推荐方法是什么?
我正在尝试这个hoogle查询,但答案都非常无益(尝试一下 - 它unsafeCoerce位于列表的顶部)
在普通的Java中,我可以写
class P {
static <A> A id (A x) { return x; }
static int y = P.<Integer>id(8);
static String bar = P.<String>id("foo");
}
Run Code Online (Sandbox Code Playgroud)
在jshell中,我可以声明和使用 id
jshell> <A> A id (A x) { return x; }
| created method id(A)
jshell> int x = id(8)
x ==> 8
jshell> String y = id("foo")
y ==> "foo"
Run Code Online (Sandbox Code Playgroud)
但我没有看到如何使类型参数明确.
jshell> String y = <String>id("foo")
| Error:
| illegal start of expression
| String y = <String>id("foo");
| ^
Run Code Online (Sandbox Code Playgroud)
隐含上下文类的名称是什么?
(允许我回答这个问题的jshell规范的一部分)在哪里?http://openjdk.java.net/jeps/222 …
我有一个多线程的Haskell程序,它调用外部程序System.Process.readProcess,并经常这样做.我该如何衡量绩效?(决定我是应该改进我的程序还是外部程序.)"外部时间"如何显示在配置文件(+ RTS -p)或事件日志(threadscope图片)中?
对于Hamlet模板机制,我理解模板在编译时被解析,导致源代码包含对blaze-html组合器的调用(以及可能因插值而导致的其他表达式).因此,插值发生的点(子树)在编译时是已知的.
在运行时,我们需要计算内插值(当然),并在树中"插入",即应用html组合器.他们都是?实际上,这些应用程序中的一些可以在编译时进行评估(那些在它们下面没有插值的应用程序).这会发生吗?
有没有办法在cabal文件中为测试(exitcode-stdio-1.0)编写命令行参数?
我可以手动运行测试
cabal test --test-options="foo bar"
Run Code Online (Sandbox Code Playgroud)
但我不想(重新)打字.
我正在从H切换到L.
import qualified Text.PrettyPrint.HughesPJ as H
import qualified Text.PrettyPrint.Leijen as L
Run Code Online (Sandbox Code Playgroud)
我在翻译H.fsep("段落填充")时遇到了问题.
这就是我要的:
H.fsep $ map ( \ d -> H.parens $ H.fsep $ replicate 4 d ) $ map (H.text . show) [1..10]
(1 1 1 1) (2 2 2 2) (3 3 3 3) (4 4 4 4) (5 5 5 5) (6 6 6 6)
(7 7 7 7) (8 8 8 8) (9 9 9 9) (10 10 10 10)
Run Code Online (Sandbox Code Playgroud)
但我只能得到这个:
L.fillSep $ map ( \ …Run Code Online (Sandbox Code Playgroud) 我不明白为什么Data.HashTable 使用Data.Hashable ,它具有hashWithSalt(唯一/基本)方法.
这不适合计算哈希值一次的自然优化,并将其存储在对象中(自然,因为Haskell对象是不可变的).
如果我想使用HashTables它,那么我被迫实施hashWithSalt.(打算1.2.0.*1.2.1.*,哈希的重新推出hash作为一个类的方法,但是这并没有帮助?)
实际的Table实现似乎没有使用hashWithSalt(HashTable.ST.Linear根本不HashTable.ST.Cuckoo使用,仅使用两个固定盐).
我有以下cabal地狱的例子:
(ghc-7.8.3在x86_64 GNU/Linux上从源代码构建,用户安装:在.cabal/config中为True)
1)在某个时间,安装了变压器-0.4.0.0(在用户空间,阴影(?)变压器-0.3来自全球空间)
2)之后,几个图书馆选择了变形金刚-0.4
3)然后,我安装提示,这取决于ghc,这取决于变压器-0.3,并且无法更改,因为ghc是硬连线的.
结果:我不能使用2)中的库并在一个项目中提示.
作为一种解决方法,我将放入constraint: transformers installed.cabal/config,并重建.有没有更好的方法来处理这种情况 - 或者首先避免它?