I do not understand an output system like F # for nested functions. This seems to be especially difficult if I use types outside of simple types like int, string, ...
here is a small example of some code that prints some reflection information
let inferenceTest () =
let t = int.GetType()
let methods = t.GetMethods() |> Seq.map(fun m -> m.Name)
printfn "%s" <| String.concat ", " methods
It's fine! No casting needed, etc. Now suppose that printing is much more active, so we want to split it into a nested function
let inferenceTestFailsToCompile () =
let printType t =
let methods = t.GetMethods() |> Seq.map(fun m -> m.Name)
printfn "%s" <| String.concat ", " methods
let t = int.GetType()
printType t
It is not possible to search for an object of an indefinite type based on information up to this point in the program. An annotation of the type may be required ... "
Why unexpectedly less information for the type system? Perhaps I could understand the problem if my function printType()were in the same area as mineinferenceTestFailsToCompile()
, t ,
let inferenceTestLambda () =
let t = int.GetType()
let printType =
let methods = t.GetMethods() |> Seq.map(fun m -> m.Name)
printfn "%s" <| String.concat ", " methods
printType