2

I am trying to use the FSharp.Data XmlProvider. According to the samples you can access nested types and create a function that will receive a parameter of one of those types. https://github.com/fsharp/FSharp.Data/blob/master/samples/library/XmlProvider.fsx (line 177)

However when I try to do the following:

type businessesT = XmlProvider<"Businesses.xml">
type businessT = businessesT.DomainTypes.Business
let testfunc (b:businessesT.DomainTypes.Business) = 
    b

It seems to work until I actually compiles and then I get

error FS0039: The type 'Business' is not defined

UPDATE: The problem can be reproduced with the sample from FSharp.Data (XmlProvider.fsx) adding a type alias after line 205

type Rss = XmlProvider<"http://tomasp.net/blog/rss.aspx">
type test = Rss.DomainTypes.Channel

What is strange is that the sample with the printDiv function is working...

Guillaume Gros
  • 341
  • 3
  • 7

2 Answers2

0

This is most likely caused by some problem with loading the type provider - if the compiler fails to load the type provider, then it cannot run it and so none of the provided types like Business would be defined.

Are you using #r in a script file, or are you referencing the type provider through "Add References" in a project? If you're using #r, check if there is any error message on that line. In case of project, check other error messages output by the compiler.

I already listed some common reasons why type provider fails to load in another answer.

Community
  • 1
  • 1
Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
  • Sorry for the lack of detail. The provider is loaded. I am using Add References and I am able to read the xml using the provider. What I can't do is access the nested types under DomainTypes. – Guillaume Gros Aug 15 '13 at 09:07
  • I did a quick test using an fsx file, like in the sample page but I get the same error when I try to define a function receiving a nested type. I am on VS2012 but do have VS2013 installed, not sure if it could interfere. – Guillaume Gros Aug 15 '13 at 09:52
0

This was probably the same problem as "type provider" not recognized when building project, which has been fixed in FSharp.Data 1.1.10

Community
  • 1
  • 1
Gustavo Guerra
  • 5,319
  • 24
  • 42