User:Gauk3/Egison

Egison is a general-purpose, dynamically-typed, pattern-match-oriented programming language.

The combination of all of the following features enables intuitive powerful pattern matching.

* Efficiency of the backtracking algoirthm for non-linear patterns

* Extensibility of pattern matching

* Polymorphisim in patterns

Egison has a similar syntax to Haskell.

Abstract
Egison language advocates a new programming paradigm called pattern-match-oriented programming.

These programming techniques allow us to redefine not only the most basic functions for list processing such as map, concat, or unique more elegantly than the traditional functional programming style, but also more practical mathematical algorithms and software such as a SAT solver, computer algebra system, and database query language that we had not been able to implement concisely.

Egison is a general-purpose, dynamically-typed, pattern-match-oriented programming language.

The combination of all of the following features enables intuitive powerful pattern matching.


 * Efficiency of the backtracking algoirthm for non-linear patterns
 * Extensibility of pattern matching
 * Polymorphisim in patterns

Egison syntax is influenced by Haskell

Code examples
A "Hello, World!" program in Egison:

Egison can use the do notation like Haskell

Egison is not a language with a static type system, so the do expression is not polymorphic.

Haskell's do expressions can be used for various monads such as List monads, Maybe monads, State monads, and IO monads, but Egison's do expressions can only be used for IO monads.

Value pattern
Example of function to enumerate Twin prime.

Patterns beginning with #, such as #(p + 2), are called value patterns, which check for equivalence of values.

A pattern match succeeds if the target of the pattern match and the content of the value pattern (in this case, #(p + 2)) are the same value.

Comparison with Haskell
Haskell version of twin primes:

Egison's version is relatively more intuitive.

Predicate pattern
Rewrite the above twin prime pattern match into a predicate pattern:

The beginning of the predicate pattern begins with  followed by a one-argument predicate.

Function argument predicates can also be patterns.

And pattern, Or pattern
As an example, the function to enumerate Prime triplet:

The or pattern  is used to match both   and.

The and pattern  is used to bind the value to   if it matches   or.

This use of the and pattern is similar to the use of the as pattern in Haskell.

Pattern Polymorphism
The same pattern can be used in pattern matching against multiple data types.

For example, the same list data may be pattern matched as multiple sets or sets in different parts of a program.

Therefore, pattern polymorphism is useful for concise pattern descriptions.

The pattern constructor as well as the value pattern are polymorphic.

Pattern Extensibility
Users can define their own matchers, which are objects to be pattern matched. For example, users can define pattern matching methods for lists, multisets, and sets, respectively.

Pattern matching with infinite length
See also function twinPrimes above.

Currying and partial application of functions
Like Haskell, Egison functions are curried.

For example, this filter function takes the two arguments, where the first argument is a predicate.

Using partial application, the function  can be defined as follows.

Other examples
Example of Reverse Polish notation Evaluator:

Features as a Computer algebra system
Egison supports symbolic computation, which has a certain CAS aspect.

Tensor index notation
The superscript is represented programmatically by  and the subscript by.

For example, the Riemann curvature tensor formula can be written directly as a program as follows.

$$R^i{}_{jkl} = \frac{\partial \Gamma^i{}_{lj}}{\partial x^k} - \frac{\partial \Gamma^i{}_{kj}}{\partial x^l} + \Gamma^i{}_{km}\Gamma^m{}_{lj} - \Gamma^i{}_{lm}\Gamma^m{}_{kj}$$