gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 06:31:35 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com