Function overloading in F#

F# doesn’t support function overloads, so you cannot write the following

let add a b = a + b
let add a b c = a  b + c

However one thing we could do is implement a discriminated union, for example

type Addition =
    | Two of int * int
    | Three of int * int * int

let add param =
    match param with
    | Two (a, b) -> a + b
    | Three (a, b, c) -> a + b + c

Now to call the function using this code we’d write

let a = add <| Three(1, 2, 3)

// or

let a = add (Three(1, 2, 3))

in C# we would use

var a = Dsl.add(Dsl.Addition.NewThree(1, 2, 3));