As John already said, your printHello
isn't a function - it is a value of type unit
. When you give printfn
all the required arguments (as you did), it does the imperative operation and return unit
(which is a type with only a single value written as ()
). You can see that writing that declaration does the printing immediately:
> let printHello = printfn "%A" "Hello";;
"Hello"
val printHello : unit = ()
When you use printHello
later, it simply refers to this unit
value (which does not carry any information).
If you want to make it a function (of type unit -> unit
) that will do something each time it is executed, then you can use the sample that John posted.
The function printfn
was not partially applied, because you gave it all the parameters it required (so it could just print immediately). If you wanted to use partial application, you could use something like:
> let printHello = printfn "%s %s" "Hello";; // Note - didn't give value for second %s
val printHello : string -> unit
Now printHello
is a function that waits for the second parameter and then runs:
> printHello "World";;
Hello World
val it : unit = ()
> printHello "F#";;
Hello F#
val it : unit = ()