## Transforming functional logic programs into monadic functional programs (2010)

### Cached

### Download Links

Venue: | In Workshop on Functional and (Constraint) Logic Programming, Draft Proceedings |

Citations: | 5 - 2 self |

### BibTeX

@INPROCEEDINGS{Braßel10transformingfunctional,

author = {Bernd Braßel and Sebastian Fischer and Michael Hanus and Fabian Reck},

title = {Transforming functional logic programs into monadic functional programs},

booktitle = {In Workshop on Functional and (Constraint) Logic Programming, Draft Proceedings},

year = {2010}

}

### OpenURL

### Abstract

Abstract. We present a high-level transformation scheme to translate lazy functional logic programs into pure Haskell programs. This transformation is based on a recent proposal to efficiently implement lazy non-deterministic computations in Haskell into monadic style. We build on this work and define a systematic method to transform lazy functional logic programs into monadic programs with explicit sharing. This results in a transformation scheme which produces high-level and flexible target code. For instance, the target code is parametric w.r.t. the concrete evaluation monad. Thus, different monad instances could, for example, define different search strategies (e.g., depth-first, breadth-first, parallel). We formally describe the basic compilation scheme and some useful extensions. 1

### Citations

141 |
TOY: A Multiparadigm Declarative System
- L¶opez-Fraguas, S¶anchez-Hern¶andez
- 1999
(Show Context)
Citation Context ... the most important features of functional and logic languages to provide a variety of programming concepts to the programmer. In particular, modern languages of this kind, such as Curry [13] or T OY =-=[16]-=-, amalgamate the concepts of demand-driven evaluation from functional programming with non-deterministic evaluation from logic programming. This combination is not only desirable to obtain efficient e... |

109 |
An approach to declarative programming based on a rewriting logic
- Gonz¶alez-Moreno, L¶opez-Fraguas, et al.
- 1999
(Show Context)
Citation Context ...esult is not desired as the operation dup is intended to duplicate a given list (rather than return the concatenation of two different lists). In order to obtain this behavior, González-Moreno et al. =-=[12]-=- proposed a rewriting logic as a logical (execution- and strategy-independent) foundation for declarative programming with non-strict and non-deterministic operations. This logic specifies the call-ti... |

91 |
How to replace failure by a list of successes
- Wadler
- 1985
(Show Context)
Citation Context ... makes the transformation of such programs into pure functional programs non-trivial. For instance, the traditional functional representation of non-deterministic computations as “lists of successes” =-=[20]-=- is not easily applicable, as one might expect, due to the arbitrary nesting of non-deterministic operations. In the following section we review a recent solution to this problem [8]. 2 Lazy, Monadic ... |

80 | Higher-order narrowing with definitional trees
- Hanus, Prehofer
- 1996
(Show Context)
Citation Context ...rd representation for functional logic programs where the strategy of pattern matching is explicitly represented by case expressions. Since source programs can be easily translated into the flat form =-=[12]-=-, we omit further details about the transformation of source programs into flat programs but define the syntax of flat programs before we present our transformation scheme. 3.1 Syntax of Flat Function... |

60 | Compiling multi-paradigm declarative programs into prolog
- Antoy, Hanus
(Show Context)
Citation Context ...early. To keep things simple, Definitions 7 and 8 introduce sharing at the beginning of a rule or the case branches, respectively. This scheme is straightforward and a similar scheme is used in PAKCS =-=[4]-=-. When implementing the transformation presented here, we observed that sharing could also be introduced individually for each variable as “late” as possible. Consequently, the ideas presented in this... |

59 |
PAKCS: The Portland Aachen Kiel Curry System. http://www.informatik.uni-kiel.de/~pakcs
- Hanus, Antoy, et al.
- 2004
(Show Context)
Citation Context ...e search space (compare [10]). Although the combination of such features is quite useful for high-level application programming, their implementation is challenging. Many older implementations (e.g., =-=[11, 16, 18]-=-) are based on Prolog’s depth-first backtracking strategy to explore the search space. Since this strategy leads to operational incompleteness and reduces the potential of modern architectures for par... |

58 | Constructor-based conditional narrowing
- Antoy
- 2001
(Show Context)
Citation Context ...his is not a loss of generality, since (1) any functional logic program (with extra variables and conditional, overlapping rules) can be transformed into an overlapping inductively sequential program =-=[1]-=-, and (2) narrowing computations in inductively sequential programs with free variables are equivalent to computations in overlapping inductively sequential programs without free variables [4, Th. 2].... |

42 | Multi-paradigm declarative languages
- Hanus
- 2007
(Show Context)
Citation Context ... different search strategies (e.g., depth-first, breadth-first, parallel). We formally describe the basic compilation scheme and some useful extensions. 1 Introduction Functional logic languages (see =-=[10]-=- for a recent survey) integrate the most important features of functional and logic languages to provide a variety of programming concepts to the programmer. In particular, modern languages of this ki... |

38 | Overlapping rules and logic variables in functional logic programs
- Antoy, Hanus
- 2005
(Show Context)
Citation Context ...inistic rules and free (logic) variables in defining rules. For the sake of simplicity, we do not consider free variables, since it has been shown that they can be replaced by non-deterministic rules =-=[4]-=-. Actually, we use a kernel language, also called overlapping inductively sequential programs [2], which are functional programs extended by a (don’t know) non-deterministic choice operator “?”. This ... |

36 | Nondeterministic Algebraic Specifications and Nonconfluent Term Rewriting
- Hussmann
- 1992
(Show Context)
Citation Context ... False Nil)” is a value of main by deriving it to “append oneBool oneBool”, and then the first argument to “Cons True Nil” and the second to “Cons False Nil” (this semantics is called run-time choice =-=[14]-=-). But this result is not desired as the operation dup is intended to duplicate a given list (rather than return the concatenation of two different lists). In or-der to obtain this behavior, González... |

31 | Evaluation strategies for functional logic programming
- Antoy
- 2005
(Show Context)
Citation Context ... consider free variables, since it has been shown that they can be replaced by non-deterministic rules [4]. Actually, we use a kernel language, also called overlapping inductively sequential programs =-=[2]-=-, which are functional programs extended by a (don’t know) non-deterministic choice operator “?”. This is not a loss of generality, since (1) any functional logic program (with extra variables and con... |

30 | Functional logic programming
- Antoy, Hanus
- 2010
(Show Context)
Citation Context ... different search strategies (e.g., depth-first, breadth-first, parallel). We formally describe the basic compilation scheme and some useful extensions. 1 Introduction Functional logic languages (see =-=[7, 13]-=- for recent surveys) integrate the most important features of functional and logic languages to provide a variety of programming concepts to the programmer. In particular, modern languages of this kin... |

22 | Encapsulating non-determinism in functional logic computations
- Braßel, Hanus, et al.
(Show Context)
Citation Context ...me choice [17]. By representing non-determinism explicitly using monads, we can collect results of non-deterministic computations in a deterministic data structure which is called encapsulated search =-=[6, 3]-=-. The monadic formulation of lazy non-determinism provides a new perspective on the problems described in previous work on encapsulated search and possibilities for future work. In a next step, we wil... |

19 | A virtual machine for functional logic computations
- Antoy, Hanus, et al.
- 2005
(Show Context)
Citation Context ...to operational incompleteness and reduces the potential of modern architectures for parallelism, more recent implementations of functional logic languages offer more flexible search strategies (e.g., =-=[5, 7]-=-). In order to avoid separate implementations for different strategies, it would be desirable to specify the search strategy (e.g., depth-first, breadth-first, parallel) as a parameter of the implemen... |

17 |
An efficient abstract machine for Curry
- Lux, Kuchen
- 1999
(Show Context)
Citation Context ...e search space (compare [10]). Although the combination of such features is quite useful for high-level application programming, their implementation is challenging. Many older implementations (e.g., =-=[11, 16, 18]-=-) are based on Prolog’s depth-first backtracking strategy to explore the search space. Since this strategy leads to operational incompleteness and reduces the potential of modern architectures for par... |

16 | A simple rewrite notion for call-time choice semantics
- López-Fraguas, Rodŕıguez-Hortalá, et al.
(Show Context)
Citation Context ...ue in both positions. Thus, “Cons True (Cons True Nil)” and “Cons False (Cons False Nil)” are the only values of main, as intended. Detailed descriptions of this operational semantics can be found in =-=[12, 13, 20]-=-. In functional logic programs, non-deterministic operations can occur in any level of the program, in particular, inside nested structures, as shown in operation oneBool above. This makes the transfo... |

14 |
The Kiel Curry System KiCS
- Braßel, Huch
- 2009
(Show Context)
Citation Context ...to operational incompleteness and reduces the potential of modern architectures for parallelism, more recent implementations of functional logic languages offer more flexible search strategies (e.g., =-=[5, 7]-=-). In order to avoid separate implementations for different strategies, it would be desirable to specify the search strategy (e.g., depth-first, breadth-first, parallel) as a parameter of the implemen... |

13 | Set functions for functional logic programming
- Antoy, Hanus
- 2009
(Show Context)
Citation Context ...me choice [21]. By representing non-determinism explicitly using monads, we can collect results of non-deterministic computations in a deterministic data structure which is called encapsulated search =-=[3, 6, 9]-=-. The monadic formulation of lazy nondeterminism provides a new perspective on the problems described in previous work on encapsulated search and possibilities for future work.In a next step, we will... |

12 | Purely functional lazy non-deterministic programming
- Fischer, Kiselyov, et al.
- 2009
(Show Context)
Citation Context ...s, it would be desirable to specify the search strategy (e.g., depth-first, breadth-first, parallel) as a parameter of the implementation. A first step towards such an implementation has been done in =-=[8]-=- where a Haskell library for non-deterministic programming w.r.t. different strategies is proposed. In this paper, we use this idea to compile functional logic programs into pure Haskell programs that... |

3 |
A fully abstract semantics for constructor systems
- López-Fraguas, Rodríguez-Hortalá, et al.
- 2009
(Show Context)
Citation Context ...without non-deterministic list elements. Nesting non-determinism inside constructors plays an essential role in achieving full abstraction in a semantics for constructor systems under run-time choice =-=[17]-=-. By representing non-determinism explicitly using monads, we can collect results of non-deterministic computations in a deterministic data structure which is called encapsulated search [6, 3]. The mo... |

2 | Computing with subspaces
- Antoy, Braßel
- 2007
(Show Context)
Citation Context ...me choice [17]. By representing non-determinism explicitly using monads, we can collect results of non-deterministic computations in a deterministic data structure which is called encapsulated search =-=[6, 3]-=-. The monadic formulation of lazy non-determinism provides a new perspective on the problems described in previous work on encapsulated search and possibilities for future work. In a next step, we wil... |

1 |
Bundles pack tighter than lists
- López-Fraguas, Rodríguez-Hortalá, et al.
- 2007
(Show Context)
Citation Context ...CC provides a programatic approach to support different search strategies, i.e., the Curry programmer can influence the search strategy by calling primitive operators provided in this system. Bundles =-=[15]-=- improve laziness in purely functional non-deterministic computations similar to our translation of data types. The type for bundles is a transformed list data type restricted to the list monad withou... |

1 | An initial (incomplete) implementation of a compiler based on this transformation scheme is available at http://www.informatik.uni-kiel.de/index.php?id= curry2monad - Fischer, Kiselyov, et al. - 2009 |