Something interesting I found out today:
I’ve seen this warning quite a lot when programming in F:
“warning FS0020: This expression should have type ‘unit’, but has type ‘SomeType’.”
for instance in something I was coding today:
let CreateDirectory d = printfn "creating directory %s" d Directory.CreateDirectory (destDir + d) //warning FS0020 () //this function has to return unit in order to be used with Array.iter Array.iter CreateDirectory dirs
The way to get rid of this warning is to pipeline the result of the function which is causing the warning into the ignore function as follows:
Directory.CreateDirectory (destDir + d) |> ignore
and hey presto your warning disappears.