如何解决工会案件之间的循环引用?

时间:2016-01-10 15:07:28

标签: f#

如何解决联合案例之间的循环引用?

type ModuleInfo = | Author of Name
                  | Section of Section
                  | Duration of Duration
                  | Url of string

我收到以下错误:

  

类型'部分'没有定义。

以下代码:

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

1 个答案:

答案 0 :(得分:9)

您可以使用and关键字:

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