I tried to write out a message to the command line using ‘printfn’. Here is my code:
Unfortunately this code doesn’t compile. Here is the compiler error I got:
The type 'string' is not compatible with the type 'Printf.TextWriterFormat<'a>'
How hard can it be to write a simple string message?
The problem becomes obvious when we look at the signature of the printfn function:
printfn : TextWriterFormat<'T> –> 'T
The function didn’t expect a string but a TextWriterFormat<'T>. The compiler has no clue how to convert our string variable to this type.
To fix this you should specify a format specification(%s in this case) and your variable: