Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get type of the module in F#

Tags:

How to get 'System.Type' of the module?

For example module:

module Foo =      let bar = 1 

And this does not work:

printfn "%s" typeof<Foo>.Name 

Error is:

The type 'Foo' is not defined 
like image 408
Mike Chaliy Avatar asked Feb 19 '10 15:02

Mike Chaliy


1 Answers

You could add a marker type to the module and then discover the module's type from that:

module Foo =       type internal Marker = interface end     let t = typeof<Marker>.DeclaringType 
like image 110
Phillip Trelford Avatar answered Nov 13 '22 13:11

Phillip Trelford