从 F# 类型提供程序提供可区分联合 [英] Providing a Discriminated Union from an F# Type Provider

查看:23
本文介绍了从 F# 类型提供程序提供可区分联合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经掌握了类型提供程序的基础知识,例如创建类型

I've gotten the basics of type providers such as creating a type

let thisAssembly = Assembly.GetExecutingAssembly()
let t = ProvidedTypeDefinition(
           thisAssembly,namespaceName,
           xType.Attribute(xname "name").Value,
           baseType = Some typeof<obj>)

但是我需要能够定义记录类型和 DU 类型,有没有办法通过类型提供程序来做到这一点?

but I need to be able to define record types and DU types is there any way to do this with type providers?

推荐答案

遗憾的是,无法在类型提供程序中定义任何 F# 特定类型,如 Discriminated Unions、Records 或 Modules,只能定义类和命名空间,这是一个有点可惜

Unfortunately, it's not possible to define any F# specific types like Discriminated Unions, Records, or Modules, in a type provider, only classes and namespaces, which is a bit unfortunate

这篇关于从 F# 类型提供程序提供可区分联合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆