*** Welcome to piglix ***

Curry (programming language)

Curry
Paradigm functional, logic, non-strict, modular
Designed by Michael Hanus, Sergio Antoy, et al.
Typing discipline static, strong, inferred
OS portable
Website Curry
Major implementations
PAKCS (with Prolog as the target), mcc (with C as the target), KiCS2 (with Haskell as the target)
Influenced by
Haskell

Curry is an experimental functional logic programming language, based on the Haskell language. It merges elements of functional and logic programming, including constraint programming integration.

It is nearly a superset of Haskell, lacking support mostly for overloading using type classes, which some implementations provide anyway as a language extension, such as the Münster Curry Compiler.

A functional program is a set of functions defined by equations or rules. A functional computation consists of replacing subexpressions by equal (with regards to the function definitions) subexpressions until no more replacements (or reductions) are possible and a value or normal form is obtained. For instance, consider the function double defined by

The expression “double 1” is replaced by 1+1. The latter can be replaced by 2 if we interpret the operator “+” to be defined by an infinite set of equations, e.g., 1+1 = 2, 1+2 = 3, etc. In a similar way, one can evaluate nested expressions (where the subexpressions to be replaced are quoted):

There is also another order of evaluation if we replace the arguments of operators from right to left:

In this case, both derivations lead to the same result, a property known as confluence. This follows from a fundamental property of pure functional languages, termed referential transparency: the value of a computed result does not depend on the order or time of evaluation, due to the absence of side effects. This simplifies the reasoning about and maintenance of pure functional programs.

As many functional languages like Haskell do, Curry supports the definition of algebraic data types by enumerating their constructors. For instance, the type of Boolean values consists of the constructors True and False that are declared as follows:

Functions on Booleans can be defined by pattern matching, i.e., by providing several equations for different argument values:

The principle of replacing equals by equals is still valid provided that the actual arguments have the required form, e.g.:

More complex data structures can be obtained by recursive data types. For instance, a list of elements, where the type of elements is arbitrary (denoted by the type variable a), is either the empty list “[]” or the non-empty list “x:xs” consisting of a first element x and a list xs:


...
Wikipedia

...