Haskell -- 如何使用新的 4 参数准引用器
看起来准引用语法已更改为现在接受 4 个参数 [ 链接]。有人用过吗?谢谢。我只想构建一些非常非常简单的东西,网络上的示例现在不起作用。
提前致谢。
It looks like the quasi quoter syntax has changed to now accept 4 arguments [ link ]. Has anyone used it yet? Thanks. I just want to build something really really simple, and the examples on the web won't work now.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
QuasiQuoter 的每个部分只是一个函数,它接受一个字符串(准引用的内容)并在
Q
monad 中返回一个适当的值。如果您的准引用器不支持在其中某些上下文中使用,则只需返回错误,例如:fail
方法调用report True
,这会产生编译器错误。这几乎是正确的行为。Each piece of the
QuasiQuoter
is just a function that takes a string (the content of the quasi-quote) and returns an appropriate value in theQ
monad. If your quasiquoter doesn't support being used in some of those contexts, just return an error, e.g.:The
fail
method callsreport True
, which produces a compiler error. This is pretty much the correct behavior.基本上,变化是您现在可以为类型和声明(除了表达式和模式之外)创建准引号。
如果您不想使用类型/声明字段,则可以将它们设置为错误“此准引用器不支持拼接类型/声明”。
Basically the changes are that you can now make quasiquoters for types and declarations (in addition to expressions and patterns).
It should be fine to set the type/declaration fields to
error "This quasiquoter doesn't support splicing types/declarations"
if you don't want to use them.