整理我的相互递归类型

发布于 2024-10-05 05:44:01 字数 160 浏览 0 评论 0原文

是否可以将相互递归类型 ([]) 分布在不同的文件中?这些类型直接位于命名空间下。

我的解决方案是将它们放在一个大文件中并使用 type ... and ... and ... 等构造。这是唯一的方法吗?

Is it possible to have mutual recursive types ([<Struct>]) spread across different files? The types are directly under a namespace.

My solution is to put them in one big file and use type ... and ... and ... etc construction. Is it the only way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永不分离 2024-10-12 05:44:01

您可以使用一种称为解开递归结的技术,在其中将一个参数化为另一个。

所以这:

type a = B of b
and b = A of a

变成:

type 'b a = B of 'b
type b = A of b a

You can use a technique called untying the recursive knot where you parameterize one over the other.

So this:

type a = B of b
and b = A of a

becomes:

type 'b a = B of 'b
type b = A of b a
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文