,我想做什么?
在ghci下打印格式和作者的关联列表。
请参见文档:
writers :: [(String, Writer)]
Association list of formats and writers. 什么已经试过了
zurgl>>>import Text.Pandoc as P
zurgl>>>P.writers
<interactive>:20:1:
No instance for (Show (WriterOptions -> Pandoc -> [Char]))
arising from a use of `print'
Possible fix:
add an instance declaration for
(Show (WriterOptions -> Pandoc -> [Char]))
In a stmt of an interactive GHCi command: print it我期望自动导入相应的show实例,但情况似乎并非如此。我必须承认,我不知道如何定义一个实例声明(Show (WriterOptions -> Pandoc -> Char) )。作为解决办法,我尝试导入Pandoc库的其他模块,但仍然没有Show实例可用。
那么我应该自己来定义这个实例吗?
如果是的话,你有什么建议与我分享以完成这项任务。
如果我不应该,有什么问题吗?
提前谢谢你的帮助。
编辑
好吧,我想我看到我太太了:
做:
zurgl>>>map (\x-> fst x) P.writers
["native","json","html","html5","html+lhs","html5+lhs","s5","slidy","slideous","dzslides","docbook","opendocument","latex","latex+lhs","beamer","beamer+lhs","context","texinfo","man","markdown","markdown+lhs","plain","rst","rst+lhs","mediawiki","textile","rtf","org","asciidoc"]我认为在我的元组里展示第二个东西是没有意义的。它是一种功能,所以我们不能展示它。
我想这应该是问题所在。
发布于 2013-02-15 15:21:07
由于元组包含两种不同的类型,所以我试图做的事情没有任何意义。
第一个是特定编写器的标识符(类型为string),第二个是写入器本身(然后是一个函数)。当然,如果我尝试全部打印,它将失败,因为函数没有显示实例。
然后,要检索Pandoc中可用的作者列表(目的是动态调用相应的函数),只需检索标识符列表,如下所示:
zurgl>>>map fst P.writers
["native","json","html","html5","html+lhs","html5+lhs","s5","slidy","slideous","dzslides","docbook","opendocument","latex","latex+lhs","beamer","beamer+lhs","context","texinfo","man","markdown","markdown+lhs","plain","rst","rst+lhs","mediawiki","textile","rtf","org","asciidoc"]https://stackoverflow.com/questions/14896231
复制相似问题