F#: How F# doesn’t require specifying parameter types in the method signature.

Found this one by mistake when I was trying to figure out how to declare optional parameters in F#. So a typical method signature would be something like this:

 member public x.CreateUserPost(userName:String, password:String) =
   1 = 1

Now let’s say you have a type named LoginModel that takes in two strings in it’s constructor:

type LoginModel(userName:String, password:String) =
  ...

And the it’s added to the method:

member public x.CreateUserPost(userName:String, password:String) =
  new LoginModel(userName, password)

As you can see, LoginModel has its two parameters explicitly typed and because of this they don’t have to be explicitly typed in the method signature. With that in mind you can reduce the method signature to this:

member public x.CreateUserPost(userName, password) =
  new LoginModel(userName, password)

And that’s completely “legal” unlike the complete series of My Little Pony you have on your computer. Shameful.