Re: Proposal: Lazy matching for local patterns

From: Michael Hanus <>
Date: Wed, 24 Oct 2001 12:55:55 +0200 (MEST)

Dear Wolfgang,

thanks for making the proposal which is very reasonable.
The reason why I have not considered it in the Curry report
was that I wanted to avoid the different accessor functions,
but in the meantime I also learned that it is in some cases
better to have lazy matching for local declarations.
Thus, I agree.

Concerning the question of the evaluation mode for accessor
functions, I have the feeling that they should be rigid
since it avoids the strange problems you mentioned and
in my applications there was no need to have them flexible.
So, if there is no good example where this is necessary,
we should take the approach of "least astonishment", i.e.,
make them rigid.

Mario Rodriguez-Artalejo wrote:
> Wolgang proposes to eliminate local pattern declarations. It seems to me
> that the translation does not work in the case of recursive local definitions.
> Consider for example the definition
> f x = let {xs = x:xs} in head (tail xs)
> In Haskell, (f 0) evaluates to 0, while the translation proposed by Wolgang
> cannot be applied because free (x:xs) is not a subset of free (f x).
> Maybe the translation is not meant to be used for recursive local definitions.

I suppose this is what Wolfgang intended since recursive
local definitions of patterns are not allowed in Curry.
The simple reason for this restriction is that this would
require to go beyond term rewriting (since you cannot translate
such definitions into standard rewrite rules) which makes many things
technically more complicated. Nevertheless, local recursive
definitions of functions are allowed, i.e., you can rewrite
the above example to the valid Curry program

   f x = let {xs z = x : xs z} in head (tail (xs 0))

(by adding an argument to xs).

Best regards,

curry mailing list
Received on Mi Okt 24 2001 - 13:04:01 CEST

This archive was generated by hypermail 2.3.0 : So Aug 01 2021 - 07:15:03 CEST