美文网首页
stackoverflow上对monad(幺半群的解释)

stackoverflow上对monad(幺半群的解释)

作者: 刘刘刘月月啊 | 来源:发表于2018-08-18 14:30 被阅读0次

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 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.

And of those endofunctors, some of them might be monads. Which ones are monads? Just 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:

A monoid is...

A set, S

An operation, • : S × S → S

An element of Se : 1 → S

...satisfying these laws:

(a • b) • c = a • (b • c), for all ab and c in S

e • a = a • e = a, for all a in S

A monad is...

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 (also known as join in Haskell)

A natural transformation, η : I → T, where I is the identity endofunctor on X (also known as return in Haskell)

...satisfying these laws:

μ ∘ 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.

相关文章

  • stackoverflow上对monad(幺半群的解释)

    All told, a monad in X is just a monoid in the category o...

  • Monad

    Monad不就是个自函子范畴上的幺半群,这有什么难理解的(A monad is just a monoid in ...

  • 一个Monad的不严谨介绍

    一个单子(Monad)说白了不过就是自函子范畴上的一个幺半群而已,这有什么难以理解的?* 之前了解了下Monad,...

  • Kotlin(十七)函数式编程<3>

    函数式通用结构设计 介绍一个非常让人恶心的专业术语,Monad。(单子)Monad 无非就是个自函子范畴上的幺半群...

  • 范畴论、类型类

    每个范畴化的幺半群都会定义一个唯一的伴随二元运算的集合的幺半群 Promise 本身,就是一种 Monad Mon...

  • Monad不过是自函子上的幺半群罢了

    Monad不过是自函子上的幺半群罢了。学了Haskell的同学,凡是看不懂这句话的,都是大学离散数学课没学好的。当...

  • Scala和范畴论 -- 对Monad的一点认识

    背景 所有一切的开始都是因为这句话:一个单子(Monad)说白了不过就是自函子范畴上的一个幺半群而已,有什么难以理...

  • 44.伴随函子的例子:自由幺半群

    a.考虑幺半群和幺半群同态构成的范畴。 基础集函子(实际上就是遗忘函子)有左伴随。 作用效果是,对每一个给定的集合...

  • 群的概念

    1.1.8设是数域上的线性空间,证明上有一组基。1.2.5举出一个半群的例子,它不是含幺半群;再举一个含幺半群的例...

  • google polymer 单向绑定 与 双向绑定

    先来看看stackoverflow上的解释@stackoverflow 注⚠️:view object的定义见下图...

网友评论

      本文标题:stackoverflow上对monad(幺半群的解释)

      本文链接:https://www.haomeiwen.com/subject/cwdfiftx.html