
Is there any reason not to include Scala-like anonymous arguments in Haskell? For example, I would like to write map (\x -> foo x 3) as map (foo _ 3) The named argument in this and similar cases adds nothing but visual and namespace clutter.

(`foo` 3)
Scala is very limited when it comes to this point free code.
On 29/12/2013 10:17 PM, "harry"
Is there any reason not to include Scala-like anonymous arguments in Haskell? For example, I would like to write map (\x -> foo x 3) as map (foo _ 3)
The named argument in this and similar cases adds nothing but visual and namespace clutter.
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Tony Morris
(`foo` 3) Scala is very limited when it comes to this point free code.
On 29/12/2013 10:17 PM, "harry"
wrote: Is there any reason not to include Scala-like anonymous arguments in Haskell? For example, I would like to write map (\x -> foo x 3) as map (foo _ 3) The named argument in this and similar cases adds nothing but visual and namespace clutter.
How about a slightly more complex example? map (\x -> foo 4 'f' (bar x) 5 'j') There comes a point where point-free notation becomes unreadable.

On 2013-12-29 13:47, harry wrote:
Tony Morris
writes: (`foo` 3) Scala is very limited when it comes to this point free code.
On 29/12/2013 10:17 PM, "harry"
wrote: Is there any reason not to include Scala-like anonymous arguments in Haskell? For example, I would like to write map (\x -> foo x 3) as map (foo _ 3) The named argument in this and similar cases adds nothing but visual and namespace clutter.
How about a slightly more complex example?
map (\x -> foo 4 'f' (bar x) 5 'j')
There comes a point where point-free notation becomes unreadable.
If you write map (foo 4 'f' (bar _) 5 'j') How would the compiler know whether you meant map (\x -> foo 4 'f' (bar x) 5 'j') or map (foo 4 'f' (\x -> bar x) 5 'j') ? Lambda's make it explicit where the variable is bound, which is a good thing, IMO. Twan

Twan van Laarhoven
If you write
map (foo 4 'f' (bar _) 5 'j')
How would the compiler know whether you meant
map (\x -> foo 4 'f' (bar x) 5 'j') or map (foo 4 'f' (\x -> bar x) 5 'j') ?
Interesting question, what does Scala do for this? I guess there would be a rule of always binding to the outermost or innermost scope.

I've seen the question asked on stackoverflow before. It will be a very
subtle bug that scala does not catch for you. You just have to have the
discpline not to nest multiple anonymous functions with underscore
arguments. There's no way for the compiler to disallow it because it
cannot tell a mistake from something that is intentional.
On Sun, Dec 29, 2013 at 8:39 AM, harry
Twan van Laarhoven
writes: If you write
map (foo 4 'f' (bar _) 5 'j')
How would the compiler know whether you meant
map (\x -> foo 4 'f' (bar x) 5 'j') or map (foo 4 'f' (\x -> bar x) 5 'j') ?
Interesting question, what does Scala do for this? I guess there would be a rule of always binding to the outermost or innermost scope.
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (4)
-
David McBride
-
harry
-
Tony Morris
-
Twan van Laarhoven