我正在使用Text.XML.Light和Scrap你的Boilerplate编写XML(de)序列化程序(在http://github.com/finnsson/Text.XML.Generic),到目前为止,我得到了"正常"ADT的工作代码但我坚持反复化存在主义.
我得到了存在主义数据类型
data DataBox where
DataBox :: (Show d, Eq d, Data d) => d -> DataBox
Run Code Online (Sandbox Code Playgroud)
而我正在尝试将其编译
instance Data DataBox where
gfoldl k z (DataBox d) = z DataBox `k` d
gunfold k z c = k (z DataBox) -- not OK
toConstr (DataBox d) = toConstr d
dataTypeOf (DataBox d) = dataTypeOf d
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何实现gunfold的DataBox.
错误消息是
Text/XML/Generic.hs:274:23:
Ambiguous type variable `b' in the constraints:
`Eq b'
arising from a use of `DataBox' at …Run Code Online (Sandbox Code Playgroud) 如果我得到了这条线
> { -# OPTIONS_GHC -fglasgow-exts -XTemplateHaskell #- }
Run Code Online (Sandbox Code Playgroud)
在.cabal文件的文档部分(描述)中,我将收到错误消息
haddock: parsing haddock prologue failed
Run Code Online (Sandbox Code Playgroud)
跑步的时候
$ cabal haddock
Run Code Online (Sandbox Code Playgroud)
但如果我摆脱了{,}一切正常.有没有办法逃脱,{}所以他们可以在描述中使用?
如何在Cocoa AppKit应用程序中实现缩放/缩放(即不是最大化窗口而是缩放窗口及其所有子视图)?我认为它在iOS中称为zoomScale.它可以使用Core Animations或Quartz 2D(例如CGContextScaleCTM)完成,还是我被迫在我的所有NSView,NSCell等中手动实现它?
ParseError在Parsec中提出错误()的首选方法是什么?我在执行检查的解析器中获得了一些代码,如果检查失败,ParseError则应返回(即Left ParseError运行时parse).
我正在尝试在Haskell中编译泛型类/类型模式的简单示例(请参阅http://www.haskell.org/ghc/docs/latest/html/users_guide/generic-classes.html)但它不会编译.关于代码有什么问题的任何想法都会有所帮助.
根据该文件应该有一个模块Generics与数据类型Unit,:*:以及:+:约但GHC(6.12.1)投诉Not in scope: data constructor 'Unit'等.
好像有一个包即时泛型与数据类型:*:,:+:以及U但是当我输入(而不是该模块Generics),我得到的错误
Illegal type pattern in the generic bindings
{myPrint _ = ""}
Run Code Online (Sandbox Code Playgroud)
完整的源代码是
import Generics.Instant
class MyPrint a where
myPrint :: a -> String
myPrint {| U |} _ = ""
myPrint {| a :*: b |} (x :*: y) = "" (show x) ++ ":*:" ++ (show y)
myPrint {| a :+: …Run Code Online (Sandbox Code Playgroud)