f# - 使用生成类型提供程序创建多个根类型

标签 f# type-providers

生成类型提供者似乎在拥有多个根类型时遇到了问题。 完整的复制品可在此处获得:https://gist.github.com/dsevastianov/46d1a8495c4af46a9875 .下面的例子

#r @"SampleProvider.dll"
type Birch = Sample.Sample<"birch">
type Elm = Sample.Sample<"elm">

let birch = Birch.birch()
let elm = Elm.elm()
elm.Branches <- ([|Elm.elm()|])

在编译时失败(而不是在设计时):

FSC: error FS2014: A problem occurred writing the binary 'obj\Debug\Tests.dll': 
Error in pass3 for type Schema, error: Error in GetMethodRefAsMethodDefIdx for 
mref = (".ctor", "ZipLookup"), error: Exception of type Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter+MethodDefNotFound' was thrown.

最佳答案

事实证明,有必要为每个根类型创建单独的临时程​​序集。我修改了 Gist 以反射(reflect)解决方案:https://gist.github.com/dsevastianov/46d1a8495c4af46a9875

关于f# - 使用生成类型提供程序创建多个根类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24185357/

相关文章:

memory-management - 什么是堆栈不平衡?

f# - DU 的类型测试模式匹配

haskell - 函数式编程语言自省(introspection)

compiler-errors - 类型提供程序的 Mono FSharpC 错误

azure - 在 F# 中遍历 Azure 存储类型提供程序生成的类型

excel - 分组直到改变顺序

f# - 折叠还是选择直到无?

functional-programming - FsCheck 生成器能否创建不断增加的序列

xml - F# XML 类型提供程序 - 使用 XSD

sqlite - SQLite 的 F# 类型提供程序?