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

Wolfgang Jeltsch g9ks157k at acme.softbase.org
Mon Jul 9 18:36:11 CEST 2012


Am Montag, den 09.07.2012, 10:20 -0600 schrieb Chris Smith:
> Right, it seems to me that there are basically three reasonable proposals here:
> 
> 1. "\ of" with multiple arguments.  This is consistent with existing
> layout, and seems like a nice generalization of lambda syntax.
> 2. "case of" with a single argument.  This is consistent with existing
> layout, and seems like a nice generalization of sections.
> 3. "\" introducing layout, possibly with changes to layout rules.  A
> much more intrusive change, but it does have a nice efficiency to it.

I strongly favor a solution where lambda-case expressions start with \,
because this can be generalized to proc expressions from arrow syntax
simply by replacing the \ with proc.

Take, for example, the following function definition:

    f (Left  x) = g x
    f (Right y) = h y

Now, let’s make an arrow version of it:

    f = proc e -> case e of
            Left  x -> g -< x
            Right y -> h -< y

It would be great if we could write something like this instead:

    f = proc of
            Left  x -> g -< x
            Right y -> h -< y

This is not just a contrived issue. In my current work on Grapefruit,
I encounter this situation quite often, and I would love to get rid of
the extra overhead I have to deal with now.

Best wishes,
Wolfgang




More information about the Glasgow-haskell-users mailing list