【发布时间】:2013-06-08 01:21:41
【问题描述】:
我对@987654325@ 和Monoids 都很陌生,最近还了解了MonadPlus。在我看来,Monoid 和MonadPlus 都提供了一个具有关联二元运算和标识的类型。 (用数学术语我称之为半群。)那么Monoid 和MonadPlus 之间有什么区别?
【问题讨论】:
-
semigroup 是一个monoid 没有身份——它们是不同的东西。在实践中,我发现幺半群在编程中比半群更常见,但是如果你确实需要,可以使用一个不错的 semigroups 包。
-
另见 Matt Fenwick 的问题 "Confused by the meaning of the 'Alternative' type class and its relationship to other type classes"(完全披露:我已回答)。
标签: haskell monads typeclass monoids monadplus