Are there any pitfall I should be aware of doing so ?
Would you know of existing code dealing with the same pb I might encounter ?
Thks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, you cannot pass types as static parameters to a type provider. The static parameters passed using
MyProvider< "first argument", 42 >have to be primitive types (likestring,intand similar). I don’t see the list anywhere in the documentation, butTypeis definitely not supported.The problem with doing this is that you could pass it
typeof<MyType>whereMyTypeis declared in the same file as the file that’s using the type provider, and so the F# compiler would have to first compile the first part of a file, then invoke the provider and then continue. This sounds possible, but it is probably low-priority for the F# team.The best way to pass information about type to a type provider is to give it a type name and then lookup the type using reflection (this will only work if the type is from an already compiled assembly):