Adding constraints to curry via flat guards

Julio Mariño, José María Rey · 2005

Curry is a functional-logic language provided with a lazy evaluation strategy. This lazy behaviour is achieved, in part, by using a formalism called definitional trees. These trees provide an optimal order for reducing (to some degree) the actual parameters of functions, taking into account the shape of patterns in the left hand sides of their definition. The integration of more and more features of Constraint Programming into Curry should be as orthogonal as possible to existing features. For instance, having a function defined over several cases specified in terms of different constraints should be allowed, in the same way as pattern matching in the functional style is supported. However, this kind of definitions has not been allowed so far, and this is partly due to the absence of an analogue of definitional trees for sets of constraints. This paper reports a first proposal in this direction. A common framework for dealing with lazy pattern matching and constraint handling is presented, in the form of flat guards that can be used to obtain demand information in the same way that data patterns in the rules' left hand sides are currently used. Constraint definitional trees are introduced along with the algorithms needed for its generation from a given function definition. Traditional definitional trees are shown to be an instance of the constraint framework for constraints over algebraic data types. Due to their practical relevance, the case of constraints over numerical (non-algebraic) domains is devoted an specific treatment.

Read the paper · More papers on PaperTik