Curry
Functional logic programming language
Curry is a programming language that integrates functional and logic programming paradigms, combining Haskell-style lazy functional evaluation with the non-deterministic search and unification capabilities characteristic of logic languages…
Definition
Curry is a programming language that integrates functional and logic programming paradigms, combining Haskell-style lazy functional evaluation with the non-deterministic search and unification capabilities characteristic of logic languages like Prolog. It allows programs to define functions the way a functional language would while also expressing computations with free variables and multiple possible results, letting a single program search for solutions the way a logic program does.
Overview
Curry grew out of academic research into unifying two programming paradigms that had historically developed along separate tracks: functional programming, exemplified by languages like Haskell and ML, which emphasizes pure functions and lazy evaluation, and logic programming, exemplified by Prolog, which emphasizes declarative relations, unification, and non-deterministic search for solutions. Researchers recognized that many problems benefit from both styles simultaneously, and Curry was designed as a unified language rather than requiring developers to switch between two separate systems or awkwardly simulate one paradigm inside the other. Mechanically, Curry programs define functions much as Haskell does, using pattern matching, algebraic data types, and lazy evaluation so that expressions are only computed when their results are actually needed. What distinguishes Curry is its support for free variables and non-deterministic functions, meaning a computation can have multiple possible results, and the runtime uses a resolution strategy combining narrowing, a technique that unifies logic-style unification with functional-style term rewriting, to search through the space of possible bindings and find valid solutions to a given expression. This lets a Curry program express search problems, such as finding values that satisfy a set of constraints, in a way that would require substantially more explicit machinery in a purely functional language. Among multi-paradigm languages, Curry sits closest to Mercury, another language merging logic and functional programming ideas, though the two differ in their underlying execution models and type systems; Mercury emphasizes strict, statically verified logic programming with strong mode and determinism declarations, while Curry leans more heavily on lazy functional evaluation combined with non-determinism as its core mechanism. Compared to Prolog alone, Curry adds a full functional programming layer with static typing and pattern matching that Prolog's untyped, purely relational model does not provide. In practice, Curry is used primarily in academic and research settings to explore problems well suited to combined functional-logic reasoning, such as constraint-based search, program verification, and modeling problems with multiple valid solutions. Several research implementations of Curry exist, each exploring different aspects of the language's execution model, and it has served as a testbed for ideas that later influenced other functional-logic and constraint programming research. The language's primary limitation is its scope of adoption: Curry remains almost entirely a research and teaching language rather than one used in commercial software development, and its non-deterministic evaluation model, while powerful for search-oriented problems, requires a different way of thinking than either pure functional or pure logic programming alone, which raises the learning curve for newcomers unfamiliar with both paradigms.
Key Features
- Combines Haskell-style lazy functional evaluation with logic programming
- Supports free variables and non-deterministic function results
- Uses narrowing to unify logic-style search with term rewriting
- Pattern matching and algebraic data types from functional tradition
- Statically typed unlike traditional untyped logic languages
- Expresses constraint-based search problems declaratively
- Multiple research implementations exploring different execution models
- Rooted in academic research unifying two programming paradigms