{'fraction_non_alphanumeric': 0.016885553470919325, 'fraction_numerical': 0.0, 'mean_word_length': 5.015037593984962, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Adding constraints to curry via flat guards

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.