I need to convert a string into a Literal so I can pass it as an argument to CsvProvider. But I am not able to do it. The code below runs with no problems:
open System.IO
open FSharp.Data
open FSharp.Data.JsonExtensions
let charSwitch (a: char) b x =
if x = a then
b
else
x
let jsonDataPath = Path.Combine(__SOURCE_DIRECTORY__, @"data\fractal.json")
let jsonData = JsonValue.Load(jsonDataPath)
/// Path with traded assets
let trp = ((jsonData?paths?tradedAssets).AsString() |> Core.String.map (charSwitch '\\' '/')).ToString()
printfn "trp is a standard string: %s" trp
// trp is a standard string: H:/Dropbox/Excel/Data/Fractal/Traded.csv
However, when add the following two lines
[<Literal>]
let tradedPath = trp
at the end I get the message This is not a valid constant expression or custom attribute value
.
I even tried to make a copy of trp but that did not help.
Any way to circumvent this problem?