14.11.2012 Views

Curry: An Integrated Functional Logic Language

Curry: An Integrated Functional Logic Language

Curry: An Integrated Functional Logic Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1 Introduction<br />

<strong>Curry</strong> is a universal programming language aiming at the amalgamation of the most important<br />

declarative programming paradigms, namely functional programming and logic programming.<br />

<strong>Curry</strong> combines in a seamless way features from functional programming (nested expressions, lazy<br />

evaluation, higher-order functions), logic programming (logical variables, partial data structures,<br />

built-in search), and concurrent programming (concurrent evaluation of constraints with synchronization<br />

on logical variables). Moreover, <strong>Curry</strong> provides additional features in comparison to the<br />

pure languages (compared to functional programming: search, computing with partial information;<br />

compared to logic programming: more efficient evaluation due to the deterministic evaluation of<br />

functions). Moreover, it also amalgamates the most important operational principles developed<br />

in the area of integrated functional logic languages: “residuation” and “narrowing” (see [21] for a<br />

survey on functional logic programming).<br />

The development of <strong>Curry</strong> is an international initiative intended to provide a common platform<br />

for the research, teaching 1 and application of integrated functional logic languages. This document<br />

describes the features of <strong>Curry</strong>, its syntax and operational semantics.<br />

2 Programs<br />

A <strong>Curry</strong> program specifies the semantics of expressions, where goals, which occur in logic programming,<br />

are particular expressions (of type Success, cf. Section 4.1.2, page 15). Executing a<br />

<strong>Curry</strong> program means simplifying an expression until a value (or solution) is computed. To distinguish<br />

between values and reducible expressions, <strong>Curry</strong> has a strict distinction between (data)<br />

constructors and operations or defined functions on these data. Hence, a <strong>Curry</strong> program consists<br />

of a set of type and function declarations. The type declarations define the computational domains<br />

(constructors) and the function declarations the operations on these domains. Predicates in the<br />

logic programming sense can be considered as constraints, i.e., functions with result type Success.<br />

Modern functional languages (e.g., Haskell [27], SML [36]) allow the detection of many programming<br />

errors at compile time by the use of polymorphic type systems. Similar type systems<br />

are also used in modern logic languages (e.g., Gödel [26], λProlog [38]). <strong>Curry</strong> follows the same<br />

approach, i.e., it is a strongly typed language with a Hindley/Milner-like polymorphic type system<br />

[13]. 2 Each object in a program has a unique type, where the types of variables and operations can<br />

be omitted and are reconstructed by a type inference mechanism.<br />

2.1 Datatype Declarations<br />

A datatype declaration has the form<br />

data T α1 ... αn = C1 τ11 ... τ1n1 | · · · | Ck τk1 ... τknk<br />

1 Actually, <strong>Curry</strong> has been successfully applied to teach functional and logic programming techniques in a single<br />

course without switching between different programming languages. More details about this aspect can be found in<br />

[22].<br />

2The extension of this type system to Haskell’s type classes is not included in the kernel language but could be<br />

considered in a future version.<br />

3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!