有没有针对不懂 Lisp 的人的 Template Haskell 教程?

发布于 2024-11-02 23:12:37 字数 450 浏览 0 评论 0原文

我想学习 Template Haskell,但我发现所有教程要么假设你学过 lisp 并知道什么是 lisp 宏,要么你知道一些 cs 理论术语 - 比如拼接、准引用等…… - 或者一些关于宏的理论结果。

我无法编写一行 lisp 代码(而且,虽然我打算有一天这样做,但我现在没有时间学习它)。 Haskell 是我的第一个函数式语言,我学会了它,以至于我可以定期用它编写代码,使用 monad,applicative,理解类型系统等等......但我知道的不多(也想学习,但我我太愚蠢了...:P) 关于它背后的理论 cs 内容。所以我忽略了我通常在 TH 教程中找到的术语。

所以,问题是:是否有一个关于 TH 的教程,适合那些编写 Haskell 代码的人,而不是作为一名专业计算机科学家,而是作为一个使用编程来完成日常琐事的人,他学习 Haskell 作为他的第一个函数式语言?也许以 TH 为例介绍宏和元编程?

谢谢大家。 :)

I wanted to learn Template Haskell but all tutorials I find either assume that you learned lisp and know what lisp macros are, or that you know some cs theory jargon - things as splices, quasiquotations, etc... - or some theoretical results about macros.

I can't code a single line of lisp (and, though I intend to do this some day, I don't have the time to learn it right now). Haskell is my very first functional language and I learned it to the point that I can regularly code in it, use monads, applicative, understand the type system, etc... but I don't know much (also want to learn but I'm too stupid for it... :P) about the theoretical cs stuff behind it. So I'm oblivious to the jargon I typically find on TH tutorials.

So, the question is: is there a tutorial about TH for someone who code Haskell, not as a professional computer scientist, but just as a guy who uses programming for his daily chores, who learned Haskell as his first functional language? Maybe a introduction to macros and meta-programming that use TH as example?

Thanks all. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

多孤肩上扛 2024-11-09 23:12:37

不,我认为没有任何关于 Template Haskell 的优秀入门教程。最好的学习方法是查看示例,或者:

I从来没有发现 Lisp 是必需的,但是有术语需要学习,就像任何特定领域的库一样。

No, I don't think there are any great introductory tutorials to Template Haskell. The best way to learn is to look at examples, or:

I never found Lisp was a requirement, however there is terminology to learn, like for any domain-specific library.

爱已欠费 2024-11-09 23:12:37

我所知道的 Template Haskell 最好的入门教程是 Bulat Ziganshin 的两篇文档。来自 Haskell Wiki 的链接目前似乎已损坏,但是您可以通过 archive.org 访问它们:

The best introductory tutorials to Template Haskell I know of are two documents by Bulat Ziganshin. The links from the Haskell Wiki seem to be broken at the moment, however you can access them via archive.org:

我纯我任性 2024-11-09 23:12:37

还有原始论文Haskell 的模板元编程蒂姆·谢尔德和西蒙·佩顿·琼斯的作者可能会有所帮助:

摘要

我们提出了对纯函数式编程语言 Haskell 的新扩展,支持编译时元编程。该系统的目的是支持编译时程序的算法构造。

在编译时生成代码的能力使程序员能够实现诸如多类型程序、类宏扩展、用户定向优化(例如内联)以及从现有数据结构和函数生成支持数据结构和函数等功能。功能。

我们的设计正在 Glasgow Haskell 编译器 ghc 中实现。

Also the original paper Template metaprogramming for Haskell by Tim Sheard and Simon Peyton Jones might be helpful:

Abstract

We propose a new extension to the purely functional programming language Haskell that supports compile-time meta-programming. The purpose of the system is to support the algorithmic construction of programs at compile-time.

The ability to generate code at compile time allows the programmer to implement such features as polytypic programs, macro-like expansion, user directed optimization (such as inlining), and the generation of supporting data structures and functions from existing data structures and functions.

Our design is being implemented in the Glasgow Haskell Compiler, ghc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文