编程技术网

关注微信公众号,定时推送前沿、专业、深度的编程技术资料。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

极客时间

机器学习函子可以在 .NET (C#/F#) 中完全编码吗?:Can ML functors be fully encoded in .NET (C#/F#)?

millems 机器学习 2022-5-7 11:44 9人围观

腾讯云服务器
机器学习函子可以在 .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],还有 monad 的函式编码 [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# 中的单子函子​​

问题解答

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/

这篇关于机器学习函子可以在 .NET (C#/F#) 中完全编码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程技术网(www.editcode.net)!

腾讯云服务器 阿里云服务器
关注微信
^