Frage

I am working with FSharp and am trying to find out more information about the types i am consuming from the FSharp.Data library. For example, how can i go about find out if HttpMessageBody is a discriminated union etc from the FSharp interactive prompt?

War es hilfreich?

Lösung

You can use methods from Reflection.FSharpType to gain information:

For example

 static member IsUnion : Type * ?BindingFlags -> bool

will tell you if a type is a Union type.

More functions in the module are at MSDN

Andere Tipps

I do not think there is a simple way to get the information directly from F# interactive (but, as mentioned by John Palmer, it would not be too hard to write a helper function that gets this information using F# reflection and prints it).

However, if you're using Visual Studio or MonoDevelop (Xamarin Studio), then you should see all the information you need in the tool tip that is displayed when you hover over the type name in the editor or find it in the autocomplete:

Visual Studio showing that HttpResponseBody is a discriminated union

I believe Code Quotations is what you are looking for.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top