一个monad只是endofunctors类别中的一个monoid,这是什么问题? [英] A monad is just a monoid in the category of endofunctors, what's the problem?

查看:113
本文介绍了一个monad只是endofunctors类别中的一个monoid,这是什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁先说了以下话?

一个monad只是在 endofunctors的类别,这是什么 有问题吗?

A monad is just a monoid in the category of endofunctors, what's the problem?

还有一个不太重要的注解,这是真的吗?如果可以的话,您能给出一个解释(希望是一个没有太多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的终结者类别中的一个单义词,乘积×被终结者的组成所取代,单位由身份终结者所设定.

All told, a monad in X is just a monoid in the category of endofunctors of X, with product × replaced by composition of endofunctors and unit set by the identity endofunctor.

X 这是一个类别. Endofunctors是从类别到其自身的函子(就函数式程序员而言,通常是 all Functor,因为它们主要只处理一个类别;类型的类别-但是我离题).但是您可以想象另一个类别是" X 上的endofunctors"类别.这是一类,其中的对象是内泛函子,而态射是自然变换.

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 的那些.与其说出从单子到monoid的确切映射(因为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),对于所有 a b c S
  • 中 对于 S 中的所有 a
  • e•a = a•e = 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
  • endofunctor, T:X→X (在Haskell中,类型为* -> *的类型构造函数,具有Functor实例)
  • 自然变换 μm:T×T→T ,其中×表示函子组成(μ被称为 join 在Haskell中)
  • 自然变换 η:I→T ,其中 I X 上的身份内隐函数( η被称为 return 在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只是endofunctors类别中的一个monoid,这是什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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