Control.Category 有什么用?
如果我发现某个东西是 Monoid
或 Monad
,我就会使用各种有趣的函数,例如 foldMap
、序列
甚至mapM
。他们让我快乐。
如果我发现某个东西是Category
,我会得到什么?除了重载 id
和 (.)
之外,我还能得到什么有趣的东西吗?
If I find out that something is a Monoid
or Monad
, I get all to use all kinds of fun functions, like foldMap
, sequence
or even mapM
. They make me happy.
What do I get if I find out that something is a Category
? Do I get anything fun besides overloading id
and (.)
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,您还(应该)了解与它们相关的法律:
作为旁注:
您没有获得像
mapM
或foldMap
这样许多有趣的函数的原因是,说某物是一个类别实际上并没有说明它。我认为最有用的函数是Control.Category
中定义的函数,它们有时使代码更易于阅读:>>>
和<< ;<
Well, you also (should) get the laws associated with them:
As a side note:
The reason that you don't get that many fun functions like
mapM
orfoldMap
is, that saying something is a category is actually saying very little about it. The most useful functions I guess are the ones defined inControl.Category
, which sometimes make code easier to read:>>>
and<<<
Control.Category
只是Control.Arrow
的基础工作,您可以从中获得有趣的函数。Control.Category
is just the ground work forControl.Arrow
, and that's where you get the fun functions from.