Call to arms: lambda-case is stuck and needs your help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
73 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

Daniel Trstenjak-2

On Thu, Jul 12, 2012 at 03:13:42PM -0400, Cale Gibbard wrote:
> There are of course already lots of ways to create functions which
> don't involve \

Well, I think it should be clear that we're talking here about
anonymous functions.

> We're not exactly talking about function definitions, so much as
> expressions whose value happens to be a function. The point is just
> that there are already a few other places in the syntax where the
> omission of a value results in a function having the omitted value as
> its parameter. At least to me, it seems natural to extend that pattern
> in this case.

The question is, how self explanatory is the syntax? I think that
sections and partial function application are pretty self explanatory
just by looking at the expression, because it tells you visually pretty
well what it actually does.

'case of {}' isn't self explanatory, because you don't have a visual
hint what happend with the parameter between 'case' and 'of'.

I can see why - I think it was Simon - proposed '\of', because you could
read it as if the parameter between 'case' and 'of' is applied to the 'of'.

I don't like the version 'case of {}' and I even don't like the version
'\case of' that much, because I think both versions degrade the syntax
of Haskell, which is part of the beauty of Haskell and we shouldn't rush
in expanding it, only for pragmatic reasons.


Greetings,
Daniel

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Call to arms: lambda-case is stuck and needs your help

Jon Fairbairn
In reply to this post by Mikhail Vorozhtsov
Mikhail Vorozhtsov <[hidden email]> writes:

> Hi.
>
> After 21 months of occasional arguing the lambda-case
> proposal(s) is in danger of being buried under its own trac
> ticket comments. We need fresh blood to finally reach an
> agreement on the syntax. Read the wiki page[1], take a look
> at the ticket[2], vote and comment on the proposals!
>
> P.S. I'm CC-ing Cafe to attract more people, but please keep
> the discussion to the GHC Users list.
>
> [1] http://hackage.haskell.org/trac/ghc/wiki/LambdasVsPatternMatching
> [2] http://hackage.haskell.org/trac/ghc/ticket/4359

Apart from lambda match, the suggestions seem to me to be poor
solutions to an old piece of bad design and they don’t fit very
well with the look of haskell.

Way back at the beginning of time, I was against pattern
matching altogether as it seemed like a seductive feature that
wouldn’t generalise very well. I wanted algebraic combinations
of some form of guarded expressions. But the rest of the
committee wanted pattern matching (I think they were right — the
seductive aspect is important and if I had had my way Haskell
would not have been as popular as it is now) and it seemed
logical to have pattern matching in lambdas too. But that led to
lambdas that can fail, which I think was a bad decision.

What I would rather have happen now is that we introduce a
distinction between pure destructor patterns (where a type is
not a sum) and patterns that can fail. Then mandate that at some
future date \pattern1 -> expression will be invalid unless
pattern1 is a pure destructor, (but to begin with the compiler
would just issue a warning). Now \pattern1 -> expression has
type a -> b without a hidden exception.

Then add another lambda for patterns that can fail, eg \?
pattern -> expression, which has a type reflecting the fact that
the match can fail, eg a -> Maybe b. Add operators to combine
such lambda expressions (eg a symbol — on the lines of || — for
liftA2 mplus) and a means of getting the answer out when all the
bases are covered (something a bit handier than just having an
operator for liftA2 fromMaybe, though that would cover all the
use cases that end with \? _ -> e).

lambda match is very close to that and worked out in more
detail. So I’m against the other proposals.

--
Jón Fairbairn                                 [hidden email]


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Call to arms: lambda-case is stuck and needs your help

Mikhail Vorozhtsov
In reply to this post by Mikhail Vorozhtsov
On 07/05/2012 09:42 PM, Mikhail Vorozhtsov wrote:

> Hi.
>
> After 21 months of occasional arguing the lambda-case proposal(s) is in
> danger of being buried under its own trac ticket comments. We need fresh
> blood to finally reach an agreement on the syntax. Read the wiki
> page[1], take a look at the ticket[2], vote and comment on the proposals!
>
> P.S. I'm CC-ing Cafe to attract more people, but please keep the
> discussion to the GHC Users list.
>
> [1] http://hackage.haskell.org/trac/ghc/wiki/LambdasVsPatternMatching
> [2] http://hackage.haskell.org/trac/ghc/ticket/4359

GHC HQ has reached a consensus[1].

[1] http://hackage.haskell.org/trac/ghc/ticket/4359#comment:69

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

Wolfgang Jeltsch-2
In reply to this post by Cale Gibbard
Am Donnerstag, den 12.07.2012, 13:38 -0400 schrieb Cale Gibbard:

> Personally I don't see why everyone appears to prefer the syntax with
> \ in it over just the obvious case section syntax which was originally
> proposed.
>
> case of { ... }
>
> looks much better to me than
>
> \case of { ... }
>
> and the former makes sense to me as a simple extension of operator
> sections to another part of the syntax.
>
> Does anyone else agree?

I’m strongly opposed to the

    case of { ... }

syntax, because there seems to be no natural arrow expression analog of
it.

A notation that starts with \ (like “\case”) can be carried over to
arrow expressions by replacing the \ with proc (like in “proc case”).

Best wishes,
Wolfgang


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

Ross Paterson
On Fri, Jul 13, 2012 at 01:21:25PM +0100, Wolfgang Jeltsch wrote:
> I’m strongly opposed to the
>
>     case of { ... }
>
> syntax, because there seems to be no natural arrow expression analog of
> it.
>
> A notation that starts with \ (like “\case”) can be carried over to
> arrow expressions by replacing the \ with proc (like in “proc case”).

Remember that there is a \ in arrow notation in addition to proc.
So one might expect any abbreviation for \x -> case x of {...}
to mean the same \ thing in arrow notation too.  If the abbreviation
contained no \, there would be no way to replace it with a proc.

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needsyour help

Donn Cave-4
In reply to this post by Cale Gibbard
Quoth Cale Gibbard:
> Personally I don't see why everyone appears to prefer the syntax with
> \ in it over just the obvious case section syntax which was originally
> proposed.
>
> case of { ... }
...
> Does anyone else agree?

Yes.  I don't see this as an `anonymous function' in any special sense,
only inasmuch as the workaround in its absence involves one.  I.e., if
I for some reason had been compelled to write
   \ a -> hPutStrLn stdout a

... that wouldn't make "hPutStrLn stdout" an anonymous function in my book.
Neither is `case of ...' an anonymous function, or functions.

        Donn

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needsyour help

Wolfgang Jeltsch-2
Am Freitag, den 13.07.2012, 06:57 -0700 schrieb Donn Cave:

> Quoth Cale Gibbard:
> > Personally I don't see why everyone appears to prefer the syntax with
> > \ in it over just the obvious case section syntax which was originally
> > proposed.
> >
> > case of { ... }
> ...
> > Does anyone else agree?
>
> Yes.  I don't see this as an `anonymous function' in any special sense,
> only inasmuch as the workaround in its absence involves one.  I.e., if
> I for some reason had been compelled to write
>    \ a -> hPutStrLn stdout a
>
> ... that wouldn't make "hPutStrLn stdout" an anonymous function in my book.
> Neither is `case of ...' an anonymous function, or functions.
>
> Donn

What is an anonymous function? A function that has no name, that is, a
function that is not assigned to an identifier. So (+ 1), \x -> x + 1,
and any lambda case are all anonymous functions.

Best wishes,
Wolfgang


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needsyourhelp

Donn Cave-4
Quoth Wolfgang Jeltsch <[hidden email]>,
...
> What is an anonymous function? A function that has no name, that is, a
> function that is not assigned to an identifier. So (+ 1), \x -> x + 1,
> and any lambda case are all anonymous functions.

All right, that more general definition works for me.  It doesn't
take much away from my point, though - in any case, clarity doesn't
demand that we use \ for all these things, only for \ x -> x + 1.

        Donn

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

Gábor Lehel
In reply to this post by Cale Gibbard
On Thu, Jul 12, 2012 at 7:38 PM, Cale Gibbard <[hidden email]> wrote:

> Personally I don't see why everyone appears to prefer the syntax with
> \ in it over just the obvious case section syntax which was originally
> proposed.
>
> case of { ... }
>
> looks much better to me than
>
> \case of { ... }
>
> and the former makes sense to me as a simple extension of operator
> sections to another part of the syntax.
>
> Does anyone else agree?
>

I also completely agree, but I don't want my opinion to get in the way
of progress.


--
Your ship was caught in a monadic eruption.

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

Brandon Allbery
On Fri, Jul 13, 2012 at 9:12 PM, Gábor Lehel <[hidden email]> wrote:
On Thu, Jul 12, 2012 at 7:38 PM, Cale Gibbard <[hidden email]> wrote:
> case of { ... }
>
> looks much better to me than
>
> \case of { ... }

I also completely agree, but I don't want my opinion to get in the way
of progress.

I don't much care whether what is implemented is "\case" or "case of" or even "\of" (even though that last reads weird), but "\case of" strikes me as including syntactic noise (a pointless extra token).  One or the other; not both.

--
brandon s allbery                                      [hidden email]
wandering unix systems administrator (available)     (412) 475-9364 vm/sms


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

Wolfgang Jeltsch-2
In reply to this post by Ross Paterson
Am Freitag, den 13.07.2012, 13:40 +0100 schrieb Ross Paterson:
> Remember that there is a \ in arrow notation in addition to proc.
> So one might expect any abbreviation for \x -> case x of {...}
> to mean the same \ thing in arrow notation too.

I completely agree. I had forgotten about the \ in arrow notation.

> If the abbreviation contained no \, there would be no way to replace
> it with a proc.

Exactly. It seems, however, that it has finally been decided to use the
syntax with \case, so all looks good so far. :-)

Best wishes,
Wolfgang



_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: [Haskell-cafe] Call to arms: lambda-case is stuck and needs your help

Wolfgang Jeltsch-2
Am Montag, den 16.07.2012, 21:26 +0300 schrieb Wolfgang Jeltsch:
> Am Freitag, den 13.07.2012, 13:40 +0100 schrieb Ross Paterson:
> > Remember that there is a \ in arrow notation in addition to proc.
> > So one might expect any abbreviation for \x -> case x of {...}
> > to mean the same \ thing in arrow notation too.
>
> I completely agree. I had forgotten about the \ in arrow notation.

I have opened a new ticket for arrow analogs of lambda case and
multi-way if:

    <http://hackage.haskell.org/trac/ghc/ticket/7081>

Best wishes,
Wolfgang


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Call to arms: lambda-case is stuck and needs your help

Mikhail Vorozhtsov
In reply to this post by Mikhail Vorozhtsov
Good news everyone. LambdaCase and MultiWayIf are now in HEAD. Thanks
for participating in the final push!

On Thu, Jul 5, 2012 at 9:42 PM, Mikhail Vorozhtsov
<[hidden email]> wrote:
>
> Hi.
>
> After 21 months of occasional arguing the lambda-case proposal(s) is in danger of being buried under its own trac ticket comments. We need fresh blood to finally reach an agreement on the syntax. Read the wiki page[1], take a look at the ticket[2], vote and comment on the proposals!
>
> P.S. I'm CC-ing Cafe to attract more people, but please keep the discussion to the GHC Users list.
>
> [1] http://hackage.haskell.org/trac/ghc/wiki/LambdasVsPatternMatching
> [2] http://hackage.haskell.org/trac/ghc/ticket/4359

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
1234