I suggest we ...

Define a function the same way as define lambda

Currently the way we define function is: let add1 x = x +1 which is not consistent with the way we define lambda fun x -> x +1. More importantly this will help new learner like me easily distinguish between a function and a value. When reading code, I always find it easier to find a lambda expression because of the fun keyword and the -> than the function. Since code is read more than write it would help save time too.

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

    3 comments

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

        Currently "fun add1 x -> x + 1" is a (curried) lambda function, so you cannot use this syntax for anything else.

      • Vanh Phom commented  ·   ·  Flag as inappropriate

        What I mean is:
        fun add1 x -> x + 1 define a function name add1 with parameter x and body x + 1
        fun x -> x +1 define a no name function (lambda) with parameter x and body x + 1

      • Richard Gibson commented  ·   ·  Flag as inappropriate

        Sorry, I guess I'm not sure what you're asking for.

        let add1 x = x + 1

        is just short for

        let add1 = fun x -> x + 1

        Both are legal F#. Is there something else you're after?

      F# Language

      Feedback and Knowledge Base