Template Haskell

Template Haskell

Template Haskell is an experimental language extension to the programming language Haskell implemented in the Glasgow Haskell Compiler (version 6 and later).

In early incarnations it was also known as Template Meta-Haskell.

It allows compile-time metaprogramming and generative programming by means of manipulating abstract syntax trees and 'splicing' results back into a program. The abstract syntax is represented using ordinary Haskell data types and the manipulations are performed using ordinary Haskell functions.

'Quasi-quote' brackets [| and |] are used to get the abstract syntax tree for the enclosed expression and 'splice' brackets $( and ) are used to convert from abstract syntax tree into code.

Example

A common idiom is to quasi-quote an expression, perform some transformation on the expression and splice the result back into the program. It could be written as:

foo = $( transform [| bar |] )

External links

* [http://www.haskell.org/haskellwiki/Template_Haskell Template Haskell Wiki Page]
* [http://www.haskell.org/th/ The Template Haskell Home Page (rather old at this moment)]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Template metaprogramming — is a metaprogramming technique in which templates are used by a compiler to generate temporary source code, which is merged by the compiler with the rest of the source code and then compiled. The output of these templates include compile time… …   Wikipedia

  • Haskell — Класс языка: функциональный, ленивый, модульный Тип исполнения: компилируемый, интерпретируемый Появился в: 1990 …   Википедия

  • Haskell — Auteur le comité Haskell Développeurs la communauté Haskell …   Wikipédia en Français

  • Хаскелл — Haskell Семантика: функциональный Тип исполнения: интерпретируемый, компилируемый Появился в: 1990 г. Типизация данных: статическая …   Википедия

  • Хаскел — Haskell Семантика: функциональный Тип исполнения: интерпретируемый, компилируемый Появился в: 1990 г. Типизация данных: статическая …   Википедия

  • Хаскель — Haskell Семантика: функциональный Тип исполнения: интерпретируемый, компилируемый Появился в: 1990 г. Типизация данных: статическая …   Википедия

  • Metaprogramming — This article is about the computer programming technique. For the management technique, see Metaprogramming (management). Programming paradigms Agent oriented Automata based Component based …   Wikipedia

  • Сравнение языков программирования — Эту статью следует викифицировать. Пожалуйста, оформите её согласно правилам оформления статей.  Условные обозначения  …   Википедия

  • HAppS — Infobox Software name = HAppS logo = caption = author = Alex Jacobson developer = released = latest release version = 0.8.8 latest release date = release date|2007|03|06 latest preview version = Darcs latest preview date = release date|2007|06|21 …   Wikipedia

  • List of functional programming topics — This is a list of functional programming topics. Contents 1 Foundational concepts 2 Lambda calculus 3 Combinatory logic 4 Intuitionistic logic …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”