本文介绍了monad 只是一个内函子范畴中的幺半群,有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是谁先说的?

monad 只是一个幺半群内函子的范畴,是什么问题?

另外一个不太重要的问题是,这是真的吗?如果是,您能否给出解释(希望没有太多 Haskell 经验的人能够理解)?

And on a less important note, is this true and if so could you give an explanation (hopefully one that can be understood by someone who doesn't have much Haskell experience)?

推荐答案

这个特别的措辞出自 James Iry,来自他极具娱乐性的编程语言的简要、不完整和大部分错误的历史,他虚构地将其归功于菲利普·瓦德勒.

That particular phrasing is by James Iry, from his highly entertaining Brief, Incomplete and Mostly Wrong History of Programming Languages, in which he fictionally attributes it to Philip Wadler.

原文引用自桑德斯·麦克莱恩 (Saunders Mac Lane) 在工作数学家的分类,分类理论的基础教材之一.这里是上下文,这可能是了解其确切含义的最佳场所.

The original quote is from Saunders Mac Lane in Categories for the Working Mathematician, one of the foundational texts of Category Theory. Here it is in context, which is probably the best place to learn exactly what it means.

但是,我会尝试一下.原句是这样的:

But, I'll take a stab. The original sentence is this:

总而言之,X 中的 monad 只是 X 的内函子范畴中的幺半群,乘积 × 被内函子的组合和由身份内函子设置的单元替换.

X 这里是一个类别.Endofunctors 是从一个类别到其自身的函子(就函数式程序员而言,这通常是all Functors,因为他们大多只处理一个类别;类别类型 - 但我离题了).但是您可以想象另一个类别,即X 上的结束函数"的类别.这是一类对象是自函子,态射是自然变换的范畴.

X here is a category. Endofunctors are functors from a category to itself (which is usually all Functors as far as functional programmers are concerned, since they're mostly dealing with just one category; the category of types - but I digress). But you could imagine another category which is the category of "endofunctors on X". This is a category in which the objects are endofunctors and the morphisms are natural transformations.

在这些内函子中,其中一些可能是单子.哪些是单子?正是那些在特定意义上是 monoidal 的.与其详细说明从 monad 到幺半群的精确映射(因为 Mac Lane 做得比我希望的要好得多),我只是将它们各自的定义并排放置,让您比较:

And of those endofunctors, some of them might be monads. Which ones are monads? Exactly the ones which are monoidal in a particular sense. Instead of spelling out the exact mapping from monads to monoids (since Mac Lane does that far better than I could hope to), I'll just put their respective definitions side by side and let you compare:

  • 一套,S
  • 一个操作,• : S × S → S
  • S 的一个元素,e : 1 → S
  • (a • b) • c = a • (b • c),对于所有abcS
  • e • a = a • e = a,对于S
  • 中的所有a
  • (a • b) • c = a • (b • c), for all a, b and c in S
  • e • a = a • e = a, for all a in S
  • 一个内函子,T : X → X(在 Haskell 中,类型构造函数 * -> * 带有一个 Functor 实例)
  • 自然变换,μ : T × T → T,其中 × 表示函子组合(μ被称为 join 在 Haskell 中)
  • 自然变换,η : I → T,其中 IX (η 被称为 return in Haskell)
  • An endofunctor, T : X → X (in Haskell, a type constructor of kind * -> * with a Functor instance)
  • A natural transformation, μ : T × T → T, where × means functor composition (μ is known as join in Haskell)
  • A natural transformation, η : I → T, where I is the identity endofunctor on X (η is known as return in Haskell)
  • μ ∘ Tμ = μ ∘ μT
  • μ ∘ Tη = μ ∘ ηT = 1(恒等自然变换)
  • μ ∘ Tμ = μ ∘ μT
  • μ ∘ Tη = μ ∘ ηT = 1 (the identity natural transformation)

稍微眯一下眼睛,您可能会发现这两个定义都是相同的抽象概念.

With a bit of squinting you might be able to see that both of these definitions are instances of the same abstract concept.

这篇关于monad 只是一个内函子范畴中的幺半群,有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 19:50