Get description of types in F# Interactive?
Can I get FSI.exe, the F# Interactive tool, to describe a type for me? In other words, there is a type I know how to access (specifically, IExpression in the Infer.NET library) but I do not know which methods it provides. I am hoping that I can use fsi to get a description of the available methods, properties, etc.
Can this be done, or is there a better way to go about it? I, sadly, do not have Visual Studio, which is how I used to get this information...
T开发者_如何学Gohanks, Nels
This depends on what you mean by "describe", and how automated a process you are looking for. It's quite easy to use the .NET reflection libraries to determine what public methods a type has. For example:
typeof<System.String>.GetMethods()
will give you an array containing MethodInfo
s for all of the public methods on the String
class. You can do exactly the same thing for any other types.
You can write a simple method to streamline the process:
let showMethods(t:System.Type) =
t.GetMethods() |> Seq.iter (printfn "%A")
精彩评论