Is there any Template Haskell tutorial for someone who doesn't know Lisp?

前端 未结 3 1786
星月不相逢
星月不相逢 2021-02-04 01:58

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

相关标签:
3条回答
  • 2021-02-04 02:53

    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.

    0 讨论(0)
  • 2021-02-04 02:59

    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:

    • First stab at Template Haskell
    • The user's manual
    • Igloo's paper :: PS

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

    0 讨论(0)
  • 2021-02-04 03:01

    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:

    • TH Tutorial
    • TH Documentation explanation
    0 讨论(0)
提交回复
热议问题