left and right sections extended

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

left and right sections extended

Christian Maeder-2
Hi,

the following sections are currently legal in Haskell:

   (a + b +) and (++ a ++ b)

because + is left and ++ is right associative.

I would like to write

    (+ 1 +) and (++ " " ++)

as legal generalized sections, too, to stay for (\ a -> (a + 1 +)) and
(\ a b -> a ++ " " ++ b) respectively.

The right-associative case would be "flip (\ b -> (++ " " ++ b))"

Such an extension would be easy to implement and it would also be a
generalization of putting parenthesis around symbols as in (+) or (++).

Extending the grammar is easy:

aexp -> ...
        | ( infixexp qop )    (left section)
        | ( qop⟨-⟩ infixexp )    (right section)

Some thoughts are needed to exclude the illegal cases (as done for left
and right sections).

Is this worth a formal proposal or is this too confusing?

Cheers Christian

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

Re: left and right sections extended

Lennart Augustsson
I'm not convinced there are enough use cases to warrant the extra complexity.

   -- Lennart (iPhone)

On Sep 30, 2011, at 14:21, Christian Maeder <[hidden email]> wrote:

> Hi,
>
> the following sections are currently legal in Haskell:
>
>  (a + b +) and (++ a ++ b)
>
> because + is left and ++ is right associative.
>
> I would like to write
>
>   (+ 1 +) and (++ " " ++)
>
> as legal generalized sections, too, to stay for (\ a -> (a + 1 +)) and (\ a b -> a ++ " " ++ b) respectively.
>
> The right-associative case would be "flip (\ b -> (++ " " ++ b))"
>
> Such an extension would be easy to implement and it would also be a generalization of putting parenthesis around symbols as in (+) or (++).
>
> Extending the grammar is easy:
>
> aexp    -> ...
>    |    ( infixexp qop )        (left section)
>    |    ( qop⟨-⟩ infixexp )        (right section)
>
> Some thoughts are needed to exclude the illegal cases (as done for left and right sections).
>
> Is this worth a formal proposal or is this too confusing?
>
> Cheers Christian
>
> _______________________________________________
> Haskell-prime mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-prime

_______________________________________________
Haskell-prime mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-prime