结构内部的签名
我想将签名/结构对放置在结构内部,如下所示:
structure Outer :> OUTER =
struct
signature INNER =
sig
...
end
structure Inner :> INNER =
struct
...
end
end
但即使是最简单的示例也会产生错误:
../test.sml:1.18-2.6 Error: syntax error: replacing STRUCT with EQUALOP ../test.sml:5.6 Error: syntax error found at END
看来结构内部不允许签名。实现此功能的最佳方法是什么?
I want to place signature/structure pair inside a structure, like so:
structure Outer :> OUTER =
struct
signature INNER =
sig
...
end
structure Inner :> INNER =
struct
...
end
end
but even the simplest of examples produces an error:
../test.sml:1.18-2.6 Error: syntax error: replacing STRUCT with EQUALOP ../test.sml:5.6 Error: syntax error found at END
It appears that signatures are not allowed inside structures. What is the best way to achieve this functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管结构嵌套在 SML 中,但签名却不然。目前尚不清楚您想要实现什么功能:
隐藏命名签名是不可能的。
使
INNER
签名依赖于结构Outer
中声明的类型是通过fibration实现的(where type
条款)。在 Benjamin Pierce 的关于编程语言高级类型的书中,Harper 和 Pierce 的教程中有一个关于纤维化的详细部分。Although structures nest in SML, signatures do not. It's not clear what functionality you want to achieve:
Hiding a named signature is impossible.
Having the
INNER
signature depend on types declared in structureOuter
is achieved through fibration (thewhere type
clause). There's a length section on fibration in the tutorial by Harper and Pierce in Benjamin Pierce's book on advanced types in programming languages.您还可以内联内部签名,如
You could also inline the inner signature, as in