Hi folks
John Hughes wrote:
>> On 1/23/06, Sebastian Sylvan <sebastian.sylvan at gmail.com> wrote:
>>>>>>> Are there any subtle reasons for why something like the following
>>> couldn't be allowed?
>>>>>>>>>> foo x y z w = ...
>>>> bar x w = foo x _ _ w
>>>>>>>> Or would (f _ x) y and f _ x y maybe be different? That would fix the
> problem above, while introducing another. Please, no!
For what it's worth, I agree with John. In my wild and foolish youth
(c1990), I implemented a programming language with this very feature. It
was a kind of higher-order LOGO on the complex plane, where a function
applied to a drawing transformed its coordinates. We'd do daft stuff like
(200 * _ ^ 2) unitsquare
What fun we had, but it was a source of top quality mystery as far as
the semantics was concerned. Figuring out how to bracket stuff was total
guesswork.
As things stand in Haskell, parentheses do grouping, and they do
sections for infix operators. These are cleanly separable, because
what's in a section bracket is plainly not an expression. Extra explicit
grouping of expressions is harmless. (f a) b is f a b. Giving
parentheses this murky binding power interferes with their innocence.
If you do want to pull a stunt like this, you need some other funny
brackets which specifically indicate this binding power, and then you
can do grouping inside them, to create larger linear abstractions. You
could have something like
(| f (_ * 3) _ |)
This makes some kind of sense, provided you don't expect to be able to
transform the contents of these brackets naively
(| flip f _ _ |) ain't (| f _ _ |)
But in my wild and foolish adulthood, I'm not sure it's worth spending a
kind of bracket on.
All the best
Conor