F# F中的类型提供程序和静态参数#

F# F中的类型提供程序和静态参数#,f#,literals,type-providers,F#,Literals,Type Providers,我有一个库,library_1,它可以正确编译并定义提供的类型: type modelforexcel = FSharpx.ExcelFile<@"template.xls", "Brokernet", true> 我希望该类型引用原始的“Brokernet.template.xls”,因此我试图提供它的完整路径,但是 type modelforexcel = FSharpx.ExcelFile<__SOURCE_DIRECTORY__+@"Brokernet.t

我有一个库,library_1,它可以正确编译并定义提供的类型:

type modelforexcel =  FSharpx.ExcelFile<@"template.xls", "Brokernet", true>
我希望该类型引用原始的“Brokernet.template.xls”,因此我试图提供它的完整路径,但是

type modelforexcel =  
   FSharpx.ExcelFile<__SOURCE_DIRECTORY__+@"Brokernet.template.xls", "Brokernet", true>
类型modelforexcel=
FSharpx.excel文件
不起作用,因为我猜它不是字面意思(?) 但“显然”定义这个文字也不起作用

[<Literal>]
let a = __SOURCE_DIRECTORY__+@"Brokernet.template.xls"
[]
设a=\uuuuuu源\目录\uuuuuu+@“Brokernet.template.xls”
有没有办法定义这样一个“动态文字”

编辑

有趣的是,如果我在第一个库的模块中定义我的类型

module Load =
   [<Literal>]
   let a = @"Brokernet.template.xls"
   type modelforexcel =  FSharpx.ExcelFile< a , "Brokernet", true>
模块加载=
[]
设a=@“Brokernet.template.xls”
键入modelforexcel=FSharpx.ExcelFile
然后,在使用第二个库中的第一个库时,不会“重新生成”该类型,并且类型提供程序不会抱怨第二个库的根中缺少该文件

这在F#的编译模型中揭示了深刻的见解,大师们可能最好地揭示了这一点。作为一个粗野的人,我只想说“代码在模块中”


PS:我想这是另外一个问题,通过适当的分阶段编译可以解决。

如注释所示,使用相对路径,例如
@.\Library\u 1\Brokernet.template.xls
解决了这个问题。

不,没有“Brokernet.template.xls”在使用第一个使用类型提供程序的库的根目录下。我会编辑使它更清楚。我不知道类型提供者。但是为什么不使用相对路径
@.\Library\u 1\Brokernet.template.xls“
?@pad确实这是一个很好的解决方案question@pad既然你的评论解决了这个问题,请考虑把它写为一个答案,所以它被标记为接受。尼古拉斯:我可以把我的评论作为答案来回答,以便结束这个问题吗?
module Load =
   [<Literal>]
   let a = @"Brokernet.template.xls"
   type modelforexcel =  FSharpx.ExcelFile< a , "Brokernet", true>