是否可以在不同文件中分布相互递归类型([<Struct>]
)?这些类型直接在 namespace 下。
我的解决方案是将它们放在一个大文件中,并使用type ... and ... and ... etc
构造。这是唯一的方法吗?
最佳答案
您可以使用一种称为“解开递归结”的技术,在此方法中,您可以一个参数化另一个参数。
所以这:
type a = B of b
and b = A of a
变成:
type 'b a = B of 'b
type b = A of b a
关于f# - 整理我的相互递归类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4308361/