Re: Curry module system and other proposals

From: Wolfgang Jeltsch <wolfgang_at_jeltsch.net>
Date: Mon, 27 Feb 2006 20:50:44 +0100

Am Montag, 27. Februar 2006 14:39 schrieb Michael Hanus:
> Wolfgang Lux wrote:
> > I wasn't thinking of records in particular, but I agree that they
> > are quite useful and I have missed them a few times. Another
> > feature I've missed is lazy pattern matching. Incidentally, this is
> > already implemented in MCC and was (silently) inherited by PAKCS,
> > so we might as well make this an official part of the language.
>
> Personally, I am not a friend of having various syntactical
> constructs for the same thing, and it seems to me that
> lazy pattern matching is already covered by let/where expressions.

http://www.haskell.org//pipermail/haskell-prime/2006-January/000077.html has
interesting thoughts concerning this topic. (The thread started with
http://www.haskell.org//pipermail/haskell-prime/2006-January/000054.html.)

> Moreover, I am not sure whether the semantic consequences of
> the little tilde in definitions like
>
> f x ~(False:ys) = if x==0 then ys else []
> f x (True:ys) = ys
>
> (note that without the tilde f is inductively sequential, whereas
> with the tilde f is overlapping) should be made explicit by
> a let declaration as in
>
> f x y = let (False:ys)=y in if x==0 then ys else []
> f x (True:ys) = ys
>
> Do you have examples showing that it is worth to hide these consequences
> in a tilde annotation instead of a let?

I think there were a mail on haskell-prime which pointed out that removal of ~
patterns may lead to complicated code.

> > I agree with Wolfgang and Frank that prelude functions should use
> > names which make their semantics clear. I would have suggested
> > unknown for this function, but any other name, e.g. free_, would
> > be okay either.
>
> I agree that "unknown" is also a good name and I prefer it since
> it avoids the strange underscore in a name like "free_".

Great!

> [...]

> > The requirement to introduce named logical variables with a
> > declaration certainly was the right idea, but we may have been
> > throwing out the baby with the bathwater by removing the ability
> > to use _ in order to introduce an anonymous logical variable.
> > Thus, we could define _ as syntactic sugar in expressions for
> > a call to a prelude function free_ (or whatever it is called),
> > just like if ... then ... else ... is considered syntactic sugar
> > for an application of the prelude function if_then_else.
>
> I also thought about this option. However, there is the problem
> that an anonymous pattern variable and an anonymous logical variable
> have the same symbol. Although this is not a problem in the
> current definition of Curry where occurrences of pattern variables
> are clearly separated from occurrences of logical variables,
> it could become a problem if one allows functional expressions
> at pattern positions as in the function pattern proposal (this
> has not been sent to this list but you can find a paper on this at
> http://www.informatik.uni-kiel.de/~mh/publications/papers/LOPSTR05.html).

I think this is a strong argument for not using _ for anonymous logical
variables.

> Nevertheless, now I think that this is not a real problem
> so that it might be worth (for the sake of readability in favor of
> "unknown") to allow an expression of the form "_" as an abbreviation
> for "unknown" or "let x free in x".

If it's already forseeable that using _ might be a problem in the future then
why use it?

> [...]

> Regards,
>
> Michael

Best wishes,
Wolfgang

_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on Di Feb 28 2006 - 08:46:40 CET

This archive was generated by hypermail 2.3.0 : Do Jun 20 2024 - 07:15:07 CEST