如何解决联合案例之间的循环引用?
type ModuleInfo = | Author of Name
| Section of Section
| Duration of Duration
| Url of string
我收到以下错误:
The type 'Section' is not defined.
代码如下:
module ManageModule.Entities
type FirstName = FirstName of string
type LastName = LastName of string
type Name = | First of FirstName
| Last of LastName
| Suffix of string option
type Duration = | Hours of int
| Minutes of int
| Seconds of int
type ModuleInfo = | Author of Name
| Section of Section
| Duration of Duration
| Url of string
type Module = Module of ModuleInfo
type Modules = Modules of ModuleInfo list
type Section = | Introduction of Module
| Conclusion of Module
最佳答案
您可以使用和
关键字:
type ModuleInfo =
| Author of Name
| Section of Section
| Duration of Duration
| Url of string
and Module = Module of ModuleInfo
and Modules = Modules of ModuleInfo list
and Section =
| Introduction of Module
| Conclusion of Module
关于f# - 如何解决联合案例之间的循环引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34706953/