I suggest we ...

Adopt the (C#/ES6) fat arrow "=>" syntax for lambda functions

"x => x+1" is just faster to write than "fun x -> x+1"

12 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Tuomas Hietanen shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    7 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • mikero commented  ·   ·  Flag as inappropriate

        Given the number of lambdas in F# code - made larger by the fact that F# doesn't support expressions with "holes" (_+_) so we need lambdas to re-arrange arguments (unless you are a combinator person), I think the succinctness of => would be nice. It does seem weird that C# code is more functionally succinct. I'd rather see support for (_ + 1) than (\x -> x+1)

      • Phylos commented  ·   ·  Flag as inappropriate

        While it may seem rather superficial, the fact that most languages that are adding lambda functions have a simple syntax is starting to make F#s' syntax look a little bit out-dated. I think replacing the "fun" keyword with Haskells' "\" would be a worthwhile change and make F# code cleaner and modern looking. Completely getting rid of the "fun" keyword may be too difficult to do, hence the suggestion of using "\".

        Rather embarrassingly, even Java and JavaScript will soon have lambda function declarations that will be more succinct than F#!!!

      • Alexei Odeychuk commented  ·   ·  Flag as inappropriate

        I think "=>" is not faster to write than "->" using any computer keyboard and it makes code look ugly, heavyweight and confusing (with = and >=).

      • trek42 commented  ·   ·  Flag as inappropriate

        Only be mildly annoyed by the (slight) verbosity of "fun", I prefer to rather use Haskell's notion (\x -> x + 1), instead of the fat arrow.

        Having both "->" and "=>" for the same thing makes the code confusing and inconsistent. Having both (fun x -> x + 1) and (\x -> x + 1) is less harmful.

      F# Language

      Feedback and Knowledge Base