Template Haskell
   HOME

TheInfoList



OR:

Template Haskell (Template Meta-Haskell for early versions) is an experimental language extension to the
functional Functional may refer to: * Movements in architecture: ** Functionalism (architecture) ** Form follows function * Functional group, combination of atoms within molecules * Medical conditions without currently visible organic basis: ** Functional s ...
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
Haskell Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
, implemented in the
Glasgow Haskell Compiler The Glasgow Haskell Compiler (GHC) is a native or machine code compiler for the functional programming language Haskell. It provides a cross-platform software environment for writing and testing Haskell code and supports many extensions, libra ...
(GHC) version 6 and later. It allows
compile time In computer science, compile time (or compile-time) describes the time window during which a language's statements are converted into binary instructions for the processor to execute. The term is used as an adjective to describe concepts relat ...
metaprogramming Metaprogramming is a computer programming technique in which computer programs have the ability to treat other programs as their data. It means that a program can be designed to read, generate, analyse, or transform other programs, and even modi ...
and
generative programming Generative may refer to: * Generative art, art that has been created using an autonomous system that is frequently, but not necessarily, implemented using a computer * Generative design, form finding process that can mimic nature’s evolutionary ...
by means of manipulating
abstract syntax tree An abstract syntax tree (AST) is a data structure used in computer science to represent the structure of a program or code snippet. It is a tree representation of the abstract syntactic structure of text (often source code) written in a formal ...
s and ' splicing' results back into a program. The abstract syntax is represented using ordinary Haskell
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
s and the manipulations are performed using ordinary Haskell functions. ' Quasi-quote' brackets regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code>
and , /code> 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. As of GHC-6.10, Template Haskell provides support for user-defined quasi-quoters, which allows users to write parsers which can generate Haskell code from an arbitrary syntax. This syntax is also enforced at compile time. For example, using a custom quasi-quoter for
regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code>
and , /code> 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. As of GHC-6.10, Template Haskell provides support for user-defined quasi-quoters, which allows users to write parsers which can generate Haskell code from an arbitrary syntax. This syntax is also enforced at compile time. For example, using a custom quasi-quoter for
regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code>
and , /code> 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. As of GHC-6.10, Template Haskell provides support for user-defined quasi-quoters, which allows users to write parsers which can generate Haskell code from an arbitrary syntax. This syntax is also enforced at compile time. For example, using a custom quasi-quoter for
regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code>
and , /code> 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. As of GHC-6.10, Template Haskell provides support for user-defined quasi-quoters, which allows users to write parsers which can generate Haskell code from an arbitrary syntax. This syntax is also enforced at compile time. For example, using a custom quasi-quoter for
regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code>
and , /code> 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. As of GHC-6.10, Template Haskell provides support for user-defined quasi-quoters, which allows users to write parsers which can generate Haskell code from an arbitrary syntax. This syntax is also enforced at compile time. For example, using a custom quasi-quoter for
regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code>
and , /code> 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. As of GHC-6.10, Template Haskell provides support for user-defined quasi-quoters, which allows users to write parsers which can generate Haskell code from an arbitrary syntax. This syntax is also enforced at compile time. For example, using a custom quasi-quoter for
regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code>
and , /code> 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. As of GHC-6.10, Template Haskell provides support for user-defined quasi-quoters, which allows users to write parsers which can generate Haskell code from an arbitrary syntax. This syntax is also enforced at compile time. For example, using a custom quasi-quoter for
regular expressions A regular expression (shortened as regex or regexp), sometimes referred to as rational expression, is a sequence of character (computing), characters that specifies a pattern matching, match pattern in string (computer science), text. Usually ...
could look like this: digitsFollowedByLetters = \d+ \s+ ,


Example

A common idiom is to quasi-quote an
expression Expression may refer to: Linguistics * Expression (linguistics), a word, phrase, or sentence * Expression (mathematics), Symbolic description of a mathematical object * Fixed expression, a form of words with a specific meaning * Idiom, a type of ...
, perform some transformation on the expression and splice the result back into the program. It could be written as: result = $( transform input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code> input , )


References


External links


Haskell.org Template Haskell Wiki page
{{Haskell programming Experimental programming languages Haskell programming language family Functional languages Metaprogramming Articles with example Haskell code