Curry (programming language): Difference between revisions

Content deleted Content added
OAbot (talk | contribs)
m Open access bot: hdl updated in citation with #oabot.
 
(16 intermediate revisions by 3 users not shown)
Line 1:
{{Short description|Programming language}}
{{About|the programming language Curry (named in honour of a mathematician and logician)|the mathematician and logician|Haskell Curry|the computer science technique|Currying}}
{{Primary sources|date=July 2019}}
{{Infobox programming language
|name = Curry
Line 16 ⟶ 15:
|platform = [[x86-64]]
|operating system = [[Cross-platform software|Cross-platform]]: [[Linux]]
|license = [[Open-sourceBSD softwarelicenses|Open-sourceBSD]] 3-clause
|website = {{URL|currywww.pages.ps.informatik.uni-kiel.de/curry-lang.org}}
|implementations = [https://www.informatik.unicurry-kiellang.deorg/~pakcs PAKCS] ([[Prolog]] target), [http://danae.uni-muenster.de/curry/ mcc] ([[C (programming language)|C]] target), [httphttps://www-ps.informatik.unicurry-kiellang.deorg/kics2/ KiCS2] ([[Haskell]] target)
|dialects =
|influenced by = [[Haskell]], [[Prolog]]
Line 24 ⟶ 23:
}}
 
'''Curry''' is a [[declarative programming]] language, an implementation of the [[functional logic programming]] paradigm,<ref>{{cite web |editor-last=Hanus |editor-first=Michael |title=Curry: A Truly Integrated Functional Logic Language |url=httphttps://www.curry-lang.org/documentation/report/}}</ref><ref>{{cite journal |last1=Sergio |first1=Antoy |last2=Hanus |first2=Michael |year=2010 |title=Functional Logic Programming |journal=Communications of the ACM |volume=53 |issue=4 |pages=74–85 |publisher=ACM |doi=10.1145/1721654.1721675 |s2cid=14578759}}</ref><ref>{{cite book |last=Hanus |first=Michael |title=Programming Logics - Essays in Memory of Harald Ganzinger |chapter=Functional Logic Programming: From Theory to Curry |series=Lecture Notes in Computer Science |year=2013 |doi=10.1007/978-3-642-37651-1_6 |volume=7797 |pages=123-168 |isbn=978-3-642-37650-4}}</ref> and based on the [[Haskell]] language. It merges elements of functional and logic programming,<ref name="Curry and Curl programming languages">
{{cite web |title=Curry experimental programming language |url=https://www.mvps.net/docs/curry-and-curl-programming-languages |website=MVPS.net |access-date=2 September 2021}}</ref> including [[constraint programming]] integration.
 
Line 91 ⟶ 90:
|pages=776–822
|publisher=ACM
|year=20072000
|issn=0004-5411
|doi=10.1145/347476.347484
| s2cid=47275506
|hdl=11858/00-001M-0000-0014-B494-9
}}</ref> proved in the 1990s that a particular narrowing strategy, ''needed narrowing'', is optimal in the sense of doing a number of reductions to get to a "normal form" corresponding to a solution that is minimal among sound and complete strategies. Needed narrowing corresponds to a lazy strategy, in contrast to the [[SLD resolution|SLD-resolution]] strategy of [[Prolog]].
|hdl-access=free
}}</ref> proved in the 1990s that a particular narrowing strategy, ''needed narrowing'', is optimal in the sense of doing a number of reductions to get to a "normal form" corresponding to a solution that is minimal among sound and complete strategies. Needed narrowing corresponds to a lazy strategy, in contrast to the [[SLD resolution|SLD-resolution]] strategy of [[Prolog]].
 
===Functional patterns===
Line 102 ⟶ 103:
last (ys++[e]) = e
</syntaxhighlight>
Haskell does not allow such a declaration since the pattern in the left-hand side contains a defined function ({{Mono|++}}). Such a pattern is also called ''functional pattern''.<ref>{{cite book |last1=SergioAntoy |first1=AntoySergio |last2=Hanus |first2=Michael |title=Logic Based Program Synthesis and Transformation |chapter=Declarative Programming with Function Patterns |series=Lecture Notes in Computer Science |year=2006 |doi=10.1007/11680093_2 |volume=3901 |pages=6–22 |isbn=978-3-540-32654-0}}</ref> Functional patterns are enabled by the combined functional and logic features of Curry and support concise definitions of tasks requiring deep pattern matching in hierarchical data structures.
 
===Non-determinism===
Line 110 ⟶ 111:
x ? y = y
 
Thus, the evaluation of the expression {{Mono|0 ? 1}} returns {{Mono|0}} as well as {{Mono|1}}. Computing with non-deterministic operations and computing with free variables by narrowing has the same expressive power.<ref>{{cite book |last1=SergioAntoy |first1=AntoySergio |last2=Hanus |first2=Michael |title=Logic Programming |chapter=Overlapping Rules and Logic Variables in Functional Logic Programs |series=Lecture Notes in Computer Science |year=2006 |doi=10.1007/11799573_9 |volume=4079 |pages=87–101 |isbn=978-3-540-36635-5}}</ref>
 
The rules defining {{Mono|?}} show an important feature of Curry: all rules are tried in order to evaluate some operation. Hence, one can define by
Line 125 ⟶ 126:
 
===Strategies===
Due to the absence of side effects, a functional logic program can be executed with different strategies. To evaluate expressions, Curry uses a variant of the ''needed narrowing'' strategy which combines [[lazy evaluation]] with non-deterministic search strategies. In contrast to Prolog, which uses backtracking to search for solutions, Curry does not fix a particular search strategy. Hence, there are implementations of Curry, like [httphttps://www-ps.informatik.unicurry-kiellang.deorg/kics2/ KiCS2], where the user can easily select a search strategy, like [[depth-first search]] (backtracking), [[breadth-first search]], iterative deepening, or parallel search.
 
==Implementations and programming tools==
There are various implementations of Curry available. The most prominent representatives are the Portland Aachen Kiel Curry System [https://www.curry-lang.org/pakcs/ PAKCS] which compiles Curry programs into [[Prolog]], the Kiel Curry System [https://www.curry-lang.org/kics2/ KiCS2] which compiles Curry programs into [[Haskell]], the Münster Curry Compiler [http://danae.uni-muenster.de/curry/ MCC], and [https://www.curry-lang.org/curry2go/ Curry2Go] which compiles Curry programs into [[Go (programming language)|Go]] programs and supports fair parallel search by mapping non-deterministic evaluations into [[light-weight process]]es (goroutines).
 
To support programming in Curry, there is a collection of [https://cpm.curry-lang.org/ Curry software packages], a [https://cpm.curry-lang.org/currygle/ Curry API search engine], a [https://github.com/fwcd/curry-language-server Curry language server] providing [[integrated development environment|IDE]] support, e.g., in [[Visual Studio Code]], as well as various program documentation and analysis tools.
==Discussion and further reading==
[[John Alan Robinson]] discussed in his invited CL2000 paper<ref>{{cite book |last=Robinson |first=John Alan |title=First International Conference on Computational Logic (CL 2000) |chapter=Computational Logic: Memories of the Past and Challenges for the Future |series=Lecture Notes in Computer Science |year=2000 |doi=10.1007/3-540-44957-4_1 |volume=1861 |pages=1-24 |isbn=978-3-540-67797-0}}</ref> the integration of functional programming with logic programming where he wrote: "It is inexplicable that the two idioms have been kept apart for so long within the computational logic repertory. We need a single programming language in which both kinds of programming are possible and can be used in combination with each other." He surveyed different attempts and concluded that Curry is the "most promising one".
 
The textbook <ref>{{cite book |last1=Louden |first1=Kenneth C. |last2=Lambert | first2=Kenneth A. |title=Programming Languages - Principles and Practice |publisher=Cengage Learning |year=2012 |isbn=978-1-111-57763-6}}</ref> about principles and practice of programming languages contains a chapter on programming in Curry.
 
==References==
Line 131 ⟶ 141:
 
==External links==
*{{Official website|https://www.curry-lang.org}}
*[https://smap.informatik.unicurry-kiellang.deorg/ Smap] - A web-based execution environment for Curry and Haskell with various example programs
*[https://cpm.curry-lang.org/ Curry packages] - A collection of software packages for Curry
*[http://danae.uni-muenster.de/curry/ MCC] - The Münster Curry Compiler, targets [[C (programming language)|C]]
*[httphttps://www.informatik.unicurry-kiellang.deorg/~pakcs/ PAKCS] A major Curry implementation, targets [[Prolog]]
*[httphttps://www-ps.informatik.unicurry-kiellang.deorg/kics2/ KiCS2] A Curry implementation, targets [[Haskell]]
*[https://www-ps.informatik.unicurry-kiellang.deorg/curry2go/ Curry2Go] A Curry implementation, targets [[Go (programming language)|Go]], and supports fair parallel search
*[https://www-psgithub.informatik.unicom/curry-kiel.delanguage/currywiki/documentation/mailing GitHub repositories] with Curry Mailingimplementations List]and tools
*[https://curry-lang.org/various/mailinglist/ Curry Mailing List]
*[http://www.informatik.uni-kielmichaelhanus.de/~mh Michael Hanus's home page]
* ''[http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.148.524 Purely Functional Lazy Non-deterministic Programming]'' (Fischer, Kiselyov, Shan, 2009), ''[http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.157.4578 Transforming Functional Logic Programs into Monadic Functional Programs]'' (Braßel, Fischer, Hanus, Reck, 2010) on modeling lazy non-deterministic (logic) programming (like in Curry) in a purely functional language ([[Haskell]]); such approach might give the programmer more flexibility in the control over the strategies that—in the case of Curry—are built-in.
 
Line 158 ⟶ 169:
<!-- Hidden categories below -->
[[Category:Articles with example Haskell code]]
[[Category:Statically typed programming languages]]