单子可以被视为计算(或计算过程)的具体化吗?

发布于 2024-10-18 02:37:41 字数 138 浏览 3 评论 0原文

在我的第一个分析中,我会回答是,但我找不到任何参考资料事实已经说得很清楚了。

In my first analysis i would answer yes, but i cannot find any reference where this fact is stated clearly.

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

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

发布评论

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

评论(2

允世 2024-10-25 02:37:41

以下链接可以说是支持您的主张的证据:

可以证明这与 Monad 无关,因为首先类函数是具体化的计算。在这种情况下,由于绑定的性质,任何给定的 monad 只是使用第一类函数的特殊情况。要了解我的出发点,请考虑 lambda 演算的函数。从某种意义上说,lambda 演算的所有函数都是具体化计算,因为它们是语言的重要部分,并且可以按照您认为合适的任何方式进行操作。函数是计算,因此可以作为参数传递的函数是具体化计算。

The following links can be said to be evidence towards your claim:

A case can be made that this has nothing to do with Monads in particular, in that first-class functions are reified computations. In that case, any given monad is just a special case of the use of first-class functions, due to the nature of bind. To see where I'm coming from here, consider the functions of the lambda calculus. In one sense, all of the functions of the lambda calculus are reified computations, since they are the significant part of the language and can be manipulated in any way you see fit. Functions are computations, and so functions that can be passed as arguments are reified computations.

洋洋洒洒 2024-10-25 02:37:41

是的,他们可以。此外,它们可以被视为(此列表非常不完整):

在这些(包括你的)中,我认为只有最后三个定义告诉我们什么是 monad:代数结构。其他一切都告诉我们 monad 的用途,给出一个(不好到有缺陷的)隐喻,说明特定的演算如何表达 monad,或者像您一样,详细说明 monad 在特定参考框架中的含义(例如 lambda 演算)。

将它们视为计算/效果的具体化,听起来像是一种本质上没有被破坏的心智模型,但我仍然建议将其抛在脑后,将单子视为一种代数结构,没有任何对用来表达它们的微积分的特定引用:原因很简单,这样做可以简化关于参考框架的推理,人们试图驯服单子(例如解析器),而不会让自己的思想陷入例如 lambda 演算中。

Yes, they can. Additionally, they can be seen as (this list is very incomplete):

  • Burritos
  • A way to do IO
  • A way to organise libraries
  • A somewhat organised heap of objects
  • Monoidal objects in a category of endofunctors
  • Lax functors from a terminal bicategory
  • An (higher-order) algebraic structure consisting of bind and return (or join and return) satisfying the monad laws

Out of these (including yours), I would claim that only the last three definitions tell us what a monad is: An algebraic structure. Everything else tells us what monads are used for, give a (bad to flawed) metaphor, say how a particular calculus expresses monads, or, like yours, elaborate what monads mean in a certain frame of reference (e.g. lambda calculus).

Viewing them as reification of computation/effects sounds like a mental model that is not inherently broken, but I would still advise to leave it behind and look at monads as an algebraic structure, devoid of any particular reference to the calculus one uses to express them: For the simple reason that doing that eases reasoning about the frame of reference one is trying to tame with a monad (say, a parser) without getting one's thoughts tangled up in, say, lambda calculus.

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