Provider Type F # Yaml

I tried using the Yaml map card in the configuration file:

Companies: - code: 11 name: A country: FR functionalCurrency: EUR - code: 12 name: B country: GB functionalCurrency: GBP 

However, when trying to read it with a type provider, it finds only the first result of the list.

Via:

  open FSharp.Configuration type CompaniesConfig = YamlConfig<"Config.yaml"> let config = CompaniesConfig() 

output:

  val config : CompaniesConfig = Companies: - code: 11 name: A country: FR functionalCurrency: EUR 

Trying to parse processed code online, so I wonder if this is a library limitation or ...?

thanks for the help

+5
source share
1 answer

You really need to download the file, not just get the circuit if you want to work with it directly: config.Load(yamlFile) . This should probably be more explicit in the documentation. I used the sample file in the link.

 #if INTERACTIVE #r @"..\packages\FSharp.Configuration.0.6.1\lib\net40\FSharp.Configuration.dll" #endif open FSharp.Configuration open System.IO /// https://github.com/fsprojects/FSharp.Configuration/blob/master/tests/FSharp.Configuration.Tests/Lists.yaml [<Literal>] let yamlFile = __SOURCE_DIRECTORY__ + "..\Lists.yaml" File.Exists yamlFile type TestConfig = YamlConfig<yamlFile> let config = TestConfig() config.Load(yamlFile) config.items.Count config.items 

And I get both elements:

 > val it : int = 2 > val it : System.Collections.Generic.IList<TestConfig.items_Item_Type> = seq [FSharp.Configuration.TestConfig+items_Item_Type {descrip = "Water Bucket (Filled)"; part_no = "A4786"; price = 147; quantity = 4;}; FSharp.Configuration.TestConfig+items_Item_Type {descrip = "High Heeled "Ruby" Slippers"; part_no = "E1628"; price = 10027; quantity = 1;}] > 
+3
source

All Articles