ML函数可以在.NET(C#/ F#)中进行完全编码吗? [英] Can ML functors be fully encoded in .NET (C#/F#)?

查看:75
本文介绍了ML函数可以在.NET(C#/ F#)中进行完全编码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ML函数可以用.NET接口和泛型实际表达吗?是否有高级ML函子使用示例违反了这种编码?

Can ML functors be practically expressed with .NET interfaces and generics? Is there an advanced ML functor use example that defies such encodings?

答案摘要

通常情况下,答案为否。 ML模块提供功能(例如通过签名共享规范[ 1 ])不会直接映射到.NET概念。

In the general case, the answer is NO. ML modules provide features (such as specification sharing via signatures [1]) that do not directly map to .NET concepts.

但是,对于某些用例,可以翻译ML习惯用语。这些情况不仅包括基本的 Set 函子[ 2 ],也包括monads的函数编码[ 3 ],甚至是Haskell的更高级用法,例如最终无标签的解释器[ 4 5 ]。

However, for certain use cases the ML idioms can be translated. These cases include not only the basic Set functor [2], but also the functorial encoding of monads [3], and even more advanced uses of Haskell, such as finally tagless interpreters [4, 5].

实际编码需要妥协,例如半安全的向下转换。

Practical encodings require compromises such as semi-safe downcasts. Your mileage will wary.

博客和代码:


  1. blog.matthewdoig.com

  2. higherlogics.blogspot.com

  3. F#中的单子函子​​

  1. blog.matthewdoig.com
  2. higherlogics.blogspot.com
  3. monad functor in F#


推荐答案

ML模块的主要功能之一是共享规范。 .NET中没有机制可以模拟它们-所需的机制太不同了。

One of the key features of ML modules is sharing specifications. There's no mechanism in .NET that would be able to emulate them - the required machinery is just too different.

您可以尝试通过将共享类型转换为参数来做到这一点。 ,但这不能忠实地模拟定义签名的能力,然后以后可能以多种不同方式对其应用共享。

You can try to do it by turning the shared types into parameters, but this can't faithfully emulate the ability to define a signature, and then later apply sharing to it, perhaps in multiple different ways.

在我看来,.NET将从确实具有这种机制的东西中受益-然后它将更接近真正支持现代语言的多样性。希望包括诸如MixML中的模块系统的最新进展,我认为这是模块系统的未来。
http://www.mpi-sws.org/~rossberg/mixml/

In my opinion, .NET would benefit from something that did have this kind of machinery - it would then come closer to truly supporting the diversity of modern languages. Hopefully including more recent advances in modules systems like those in MixML, which in my opinion is the future of module systems. http://www.mpi-sws.org/~rossberg/mixml/

这篇关于ML函数可以在.NET(C#/ F#)中进行完全编码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆