Re: Lazy Patterns (was: Curry module system and other proposals)

From: Wolfgang Lux <>
Date: Fri, 03 Mar 2006 09:41:46 +0100

Michael Hanus wrote:

> Wolfgang Lux wrote:
>> And this isn't changed by lazy patterns! After all, they are
>> merely syntactic sugar.
> Sorry for being too vague. I mean that function rules without ~
> have a direct equational interpretation, i.e., they are not syntactic
> sugar for something else. This means that if there is a rule
> f p = e, one can always (and only) use this rule to replace
> an expression obeying the same form, e.g., an expression
> sigma(f p) can be replaced by sigma(e). This property does
> no longer hold if p contains ~-patterns because then one
> can apply the equation to expressions that do not obey
> the given patterns.

I'm sorry, but I still don't get your point. After all f's pattern
is ~p and not p. These are quite distinct patterns. I would neither
expect that (Just x) and x are the same patterns or could be applied
to the same set of expressions.

> [...]
>> Your argument would equally apply to Haskell, writing code like
>> stupidNot ~True = False
>> stupidNot False = True
>> would be as wrong in Haskell as it is in Curry.
> Actually, hugs or ghc does not seem to provide any warning
> in this case. And I think this is intended because it is
> common practice in Haskell to write equations which have
> no direct equational meaning (e.g., default rules).

I don't think this is intended for ghc (Hugs does not appear to emit
warnings anyway). Ghc -Wall will emit a warning for the definition
   stupid _ = False
   stupid False = True
so I think it is rather a bug that it doesn't emit a warning when a
lazy pattern is used in the first equation.

Anyway, I think I have proved Wadler's law now long enough
once again and to put an end to this discussion, I withdraw my
proposal to include lazy patterns in Curry.


curry mailing list
Received on Fr Mär 03 2006 - 10:44:00 CET

This archive was generated by hypermail 2.3.0 : Fr Okt 15 2021 - 07:15:03 CEST