<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Declarative Multi-paradigm Programming</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Institut fur Informatik, CAU Kiel</institution>
          ,
          <addr-line>D-24098 Kiel</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>This tutorial provides an overview and introduction to declarative programming exploiting multiple paradigms, in particular, functional, logic, and constraint programming. To demonstrate the possibility to support these paradigms within a single programming model, we survey the features of the declarative multi-paradigm language Curry.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Overview
Compared to traditional imperative languages, declarative programming
languages provide a higher and more abstract level of programming that leads to
reliable and maintainable programs. However, there is no distinct \declarative
programming" paradigm. Instead, there are various programming paradigms and
related languages based on di erent methods to structure declarative knowledge.
Functional programming is based on the lambda calculus and provide functions
as computational entities. Logic programming is based on rst-order predicate
logic and uses predicates as basic programming entities. Constraint
programming o ers constraint solvers to reason about models described with the help
of various constraint structures. Although the motivation to exploit high-level
programming is similar in all paradigms, the concrete languages associated to
them are quite di erent. Thus, it is a natural idea to combine these worlds of
programming into a single paradigm, and attempts for doing so have a long
history. However, the interactions between functional and logic programming
features are complex in detail so that the concrete design of such declarative
multi-paradigm languages is a non-trivial task. This is demonstrated by a lot of
research work on the semantics, operational principles, and implementation of
functional logic languages since more than two decades. Fortunately, recent
advances in the foundation and implementation of functional logic languages have
shown reasonable principles that lead to the design of practically applicable
programming languages.</p>
      <p>
        This tutorial provides an overview on the principles of integrated functional
logic languages. As a concrete programming language, we survey the declarative
multi-paradigm language Curry1 [
        <xref ref-type="bibr" rid="ref13 ref20">13, 20</xref>
        ]. It is developed by an international
initiative of researchers in this area and intended to provide a common platform
for research, teaching, and application of integrated functional logic languages.
1 http://www.curry-language.org
Details about functional logic programming and Curry can be found in recent
surveys [
        <xref ref-type="bibr" rid="ref18 ref5">5, 18</xref>
        ] and in the language report [
        <xref ref-type="bibr" rid="ref20">20</xref>
        ].
      </p>
      <p>
        The integration of functional and logic programming has various advantages.
Beyond the fact that one can use the best features of declarative languages
in a single language, like strong typing, higher-order functions, optimal (lazy)
evaluation from functional programming, or non-determinism, computing with
partial information, and constraint solving from logic programming, there are
also clear advantages compared to the individual paradigms. For instance, the
combination of lazy evaluation and non-determinism leads to a demand-driven
exploration of the search space which is sometimes more e cient and optimal
for particular classes of programs [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Moreover, non-declarative features, which
are regularly used in practical logic programs, can be avoided in functional logic
languages, e.g., by functional notation or declarative I/O [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ].
      </p>
      <p>
        The combined features o ered by functional logic languages led to new design
patterns [
        <xref ref-type="bibr" rid="ref3 ref6">3, 6</xref>
        ], better abstractions for application programming (e.g.,
programming with databases [
        <xref ref-type="bibr" rid="ref11 ref7">7, 11</xref>
        ], GUI programming [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], web programming [
        <xref ref-type="bibr" rid="ref15 ref16 ref19">15, 16,
19</xref>
        ], string parsing [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]), and new techniques to implement programming tools,
like partial evaluators [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] or test case generators [
        <xref ref-type="bibr" rid="ref12 ref21">12, 21</xref>
        ]. In particular, functional
patterns, as proposed in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], exploit non-determinism from logic programming
and demand-driven pattern matching from functional programming in order
to achieve a powerful executable speci cation method. For instance, functional
patterns have been used for XML processing [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ] where it has been shown that
specialized logic programming approaches [
        <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
        ] can be implemented with a few
lines of code in Curry. Some of these techniques are reviewed in this tutorial.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>M.</given-names>
            <surname>Alpuente</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Falaschi</surname>
          </string-name>
          , and
          <string-name>
            <given-names>G.</given-names>
            <surname>Vidal</surname>
          </string-name>
          .
          <article-title>Partial evaluation of functional logic programs</article-title>
          .
          <source>ACM Transactions on Programming Languages and Systems</source>
          ,
          <volume>20</volume>
          (
          <issue>4</issue>
          ):
          <volume>768</volume>
          {
          <fpage>844</fpage>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>S.</given-names>
            <surname>Antoy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Echahed</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>A needed narrowing strategy</article-title>
          .
          <source>Journal of the ACM</source>
          ,
          <volume>47</volume>
          (
          <issue>4</issue>
          ):
          <volume>776</volume>
          {
          <fpage>822</fpage>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>S.</given-names>
            <surname>Antoy</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>Functional logic design patterns</article-title>
          .
          <source>In Proc. of the 6th International Symposium on Functional and Logic Programming (FLOPS</source>
          <year>2002</year>
          ), pages
          <fpage>67</fpage>
          {
          <fpage>87</fpage>
          . Springer LNCS 2441,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>S.</given-names>
            <surname>Antoy</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>Declarative programming with function patterns</article-title>
          .
          <source>In Proceedings of the International Symposium on Logic-based Program Synthesis and Transformation (LOPSTR'05)</source>
          , pages
          <fpage>6</fpage>
          <lpage>{</lpage>
          22. Springer LNCS 3901,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>S.</given-names>
            <surname>Antoy</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>Functional logic programming</article-title>
          .
          <source>Communications of the ACM</source>
          ,
          <volume>53</volume>
          (
          <issue>4</issue>
          ):
          <volume>74</volume>
          {
          <fpage>85</fpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>S.</given-names>
            <surname>Antoy</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>New functional logic design patterns</article-title>
          .
          <source>In Proc. of the 20th International Workshop on Functional</source>
          and
          <article-title>(Constraint) Logic Programming (WFLP</article-title>
          <year>2011</year>
          ), pages
          <fpage>19</fpage>
          {
          <fpage>34</fpage>
          . Springer LNCS 6816,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>B. Bra el</surname>
          </string-name>
          , M. Hanus, and
          <string-name>
            <surname>M.</surname>
          </string-name>
          <article-title>Muller. High-level database programming in Curry</article-title>
          .
          <source>In Proc. of the Tenth International Symposium on Practical Aspects of Declarative Languages (PADL'08)</source>
          , pages
          <fpage>316</fpage>
          {
          <fpage>332</fpage>
          . Springer LNCS 4902,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>F.</given-names>
            <surname>Bry</surname>
          </string-name>
          and
          <string-name>
            <surname>S.</surname>
          </string-name>
          <article-title>Scha ert. A gentle introduction to Xcerpt, a rule-based query and transformation language for XML</article-title>
          .
          <source>In Proceedings of the International Workshop on Rule Markup Languages for Business Rules on the Semantic Web (RuleML'02)</source>
          ,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>F.</given-names>
            <surname>Bry</surname>
          </string-name>
          and
          <string-name>
            <surname>S.</surname>
          </string-name>
          <article-title>Scha ert. Towards a declarative query and transformation language for XML and semistructured data: Simulation uni cation</article-title>
          .
          <source>In Proceedings of the International Conference on Logic Programming (ICLP'02)</source>
          , pages
          <fpage>255</fpage>
          {
          <fpage>270</fpage>
          . Springer LNCS 2401,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>R.</given-names>
            <surname>Caballero</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.J.</given-names>
            <surname>Lopez-Fraguas</surname>
          </string-name>
          .
          <article-title>A functional-logic perspective of parsing</article-title>
          .
          <source>In Proc. 4th Fuji International Symposium on Functional and Logic Programming (FLOPS'99)</source>
          , pages
          <fpage>85</fpage>
          {
          <fpage>99</fpage>
          . Springer LNCS 1722,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>S.</given-names>
            <surname>Fischer</surname>
          </string-name>
          .
          <article-title>A functional logic database library</article-title>
          .
          <source>In Proc. of the ACM SIGPLAN 2005 Workshop on Curry and Functional Logic Programming (WCFLP</source>
          <year>2005</year>
          ), pages
          <fpage>54</fpage>
          {
          <fpage>59</fpage>
          . ACM Press,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>S.</given-names>
            <surname>Fischer</surname>
          </string-name>
          and
          <string-name>
            <given-names>H.</given-names>
            <surname>Kuchen</surname>
          </string-name>
          .
          <article-title>Systematic generation of glass-box test cases for functional logic programs</article-title>
          .
          <source>In Proceedings of the 9th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP'07)</source>
          , pages
          <fpage>63</fpage>
          {
          <fpage>74</fpage>
          . ACM Press,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>A uni ed computation model for functional and logic programming</article-title>
          .
          <source>In Proc. of the 24th ACM Symposium on Principles of Programming Languages (Paris)</source>
          , pages
          <fpage>80</fpage>
          {
          <fpage>93</fpage>
          ,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>A functional logic programming approach to graphical user interfaces</article-title>
          .
          <source>In International Workshop on Practical Aspects of Declarative Languages (PADL'00)</source>
          , pages
          <fpage>47</fpage>
          {
          <fpage>62</fpage>
          . Springer LNCS 1753,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>High-level server side web scripting in Curry</article-title>
          .
          <source>In Proc. of the Third International Symposium on Practical Aspects of Declarative Languages (PADL'01)</source>
          , pages
          <fpage>76</fpage>
          {
          <fpage>92</fpage>
          .
          <string-name>
            <surname>Springer</surname>
            <given-names>LNCS</given-names>
          </string-name>
          <year>1990</year>
          ,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>Type-oriented construction of web user interfaces</article-title>
          .
          <source>In Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP'06)</source>
          , pages
          <fpage>27</fpage>
          {
          <fpage>38</fpage>
          . ACM Press,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>Declarative processing of semistructured web data</article-title>
          .
          <source>In Technical Communications of the 27th International Conference on Logic Programming</source>
          , volume
          <volume>11</volume>
          , pages
          <fpage>198</fpage>
          {
          <fpage>208</fpage>
          . Leibniz
          <source>International Proceedings in Informatics (LIPIcs)</source>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          .
          <article-title>Functional logic programming: From theory to Curry</article-title>
          .
          <source>In Programming Logics - Essays in Memory of Harald Ganzinger</source>
          , pages
          <volume>123</volume>
          {
          <fpage>168</fpage>
          . Springer LNCS 7797,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <given-names>M.</given-names>
            <surname>Hanus</surname>
          </string-name>
          and
          <string-name>
            <given-names>S.</given-names>
            <surname>Koschnicke</surname>
          </string-name>
          .
          <article-title>An ER-based framework for declarative web programming</article-title>
          .
          <source>Theory and Practice of Logic Programming</source>
          ,
          <volume>14</volume>
          (
          <issue>3</issue>
          ):
          <volume>269</volume>
          {
          <fpage>291</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          20. M. Hanus (ed.).
          <source>Curry: An integrated functional logic language (vers. 0.8.3)</source>
          . Available at http://www.curry-language.org,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          21.
          <string-name>
            <surname>C. Runciman</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Naylor</surname>
            , and
            <given-names>F.</given-names>
          </string-name>
          <string-name>
            <surname>Lindblad</surname>
          </string-name>
          .
          <article-title>Smallcheck and lazy smallcheck: automatic exhaustive testing for small values</article-title>
          .
          <source>In Proc. of the 1st ACM SIGPLAN Symposium on Haskell</source>
          , pages
          <volume>37</volume>
          {
          <fpage>48</fpage>
          . ACM Press,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          22.
          <string-name>
            <given-names>P.</given-names>
            <surname>Wadler</surname>
          </string-name>
          .
          <article-title>How to declare an imperative</article-title>
          .
          <source>ACM Computing Surveys</source>
          ,
          <volume>29</volume>
          (
          <issue>3</issue>
          ):
          <volume>240</volume>
          {
          <fpage>263</fpage>
          ,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>