Re: Neither PAKCS nor MCC transform right sections according to the Curry report.

From: Sebastian Fischer <sebf_at_informatik.uni-kiel.de>
Date: Sun, 20 Feb 2011 10:47:30 +0900

On Sat, Feb 19, 2011 at 7:09 PM, Wolfgang Lux <wlux_at_uni-muenster.de> wrote:

> Incidentally, the current translation of sections in the report is rather
> inconsistent.


Yes, currently right sections (should) destroy the sharing of the argument,
left sections don't (according to the report).

Before changing MCC in any way, I'd prefer having the report specify the
> translations of left and right sections consistently. Either
> (e `op`) = \x -> e `op` x
> (`op` e) = \x -> x `op` e
>

With this proposal, both left and right sections should destroy the sharing
of the argument.


> or
> (e `op`) = (\f x y -> f x y) (op) (e)
> (`op` e) = (\f x y -> f y x) (op) (e)
>

With this proposal, neither left nor right sections should destroy the
sharing of the argument. It is equivalent to

    (e `op`) = op e
    (`op` e) = flip op e

but has more symmetric syntax.


> Just for reference, the former is used in the Haskell report, but then it
> makes only a difference w.r.t. efficiency if sharing is broken in Haskell.


Yes, and IIRC GHC uses a translation that does not destroy sharing.


> As noted above, I'd prefer the report to use the second transformation,
> which has the additional advantage that no name captures are possible.
>

I am slightly in favor of your second proposal too (while I don't care so
much about symmetric syntax than about symmetric semantics). I would expect
that left and right sections behave consistently regarding sharing and
additionally that

    (plus a)
    ((+) a)
    (a+)

all have the same meaning. This either requires to change the meaning of
right sections according to Wolfgang's second proposal or to change the
meaning of left sections *and partial applications in general* according to
(a generalization of) his first, such that the partial application

    foo a b

would be translated into

    (\x -> foo a b x)

if 'foo' has arity 3.

Actually, I'm not sure which change I prefer. Maybe partial applications
with non-deterministic arguments would behave more intuitively without
sharing of the arguments (I don't know).

Changing only the meaning of right sections is certainly a more conservative
change.

Sebastian



_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry
Received on So Feb 20 2011 - 18:24:31 CET

This archive was generated by hypermail 2.3.0 : Do Feb 01 2024 - 07:15:10 CET