Haskell中的分类结构 [英] Categorical structure in Haskell

查看:74
本文介绍了Haskell中的分类结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hask是其对象是类型而态射是函数的类别. 但是,我已经看到Conor McBride(@pigworker)警告不要多次使用Hask( 1 2 3 ):

Hask is usually thought to be the category whose objects are types and morphisms are functions. However, I've seen Conor McBride (@pigworker) warn against the use of Hask multiple times (1, 2, 3):

  • 我不鼓励谈论"The Hask Category".因为它在潜意识里限制了您避免在Haskell编程中寻找其他分类结构.

  • I would discourage talk of "the Hask Category" because it subconsciously conditions you against looking for other categorical structure in Haskell programming.

请注意,我不喜欢使用"Hask"作为"Haskell类型和函数类别"的名称:我担心将一个类别标记为Haskell类别会产生不幸的副作用,使我们对Haskell编程中其他类别结构的丰富性视而不见.这是一个陷阱.

Note, I dislike the use of "Hask" as the name of the "category of Haskell types and functions": I fear that labelling one category as the Haskell category has the unfortunate side-effect of blinding us to the wealth of other categorical structure in Haskell programming. It's a trap.

我希望人们不会将其称为"Hask":它有可能限制想象力.

I wish people wouldn't call it "Hask", though: it threatens to limit the imagination.

我们可以在Haskell中看到哪些其他类别?

What other categories can we see in Haskell?

他的答案之一中,他谈到了其中一些想法,但我想知道是否有人可以对此进行扩展;我想知道是否还有更多示例.

In one of his answers, he touches upon some of these ideas, but I wonder if someone could expand upon it; and I wonder if there are even more examples.

[...]到处都有大量的类别结构,当然,在更高种类的类别中肯定有大量的类别结构可用(可能但不一定).我特别喜欢索引集的族之间的函子.

[...] there's a ton of categorical structure lurking everywhere, there's certainly a ton of categorical structure available (possibly but not necessarily) at higher kinds. I'm particularly fond of functors between indexed families of sets.

推荐答案

Haskell中的约束也构成了一个类别.对象是约束,箭头表示.因此,每个约束都暗示着自己,并且在Monad fApplicative f之间,在Ord aEq a之间以及在Ord aOrd [a]之间有一个箭头.

Constraints in Haskell also form a category. The objects are the constraints, and the arrows mean "this constraint implies this other constraint". So every constraint implies itself, and there's an arrow between Monad f and Applicative f, between Ord a and Eq a and between Ord a and Ord [a].

这是瘦类别,因此两个之间最多有一个箭头对象.

It is a thin category, so there is at most one arrow between two objects.

这篇关于Haskell中的分类结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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