Haskell 中的分类结构

Categorical structure in Haskell

Hask通常被认为是对象是类型,态射是函数的范畴。 但是,我看到 Conor McBride (@pigworker) 警告不要多次使用 Hask (, 2, ):

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

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

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

我们还能在 Haskell 中看到哪些其他类别?

one of his answers 中,他谈到了其中的一些想法,但我想知道是否有人可以扩展它;我想知道是否还有更多示例。

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

我曾经上传过一个演示此示例的教育包。我称之为 MHask。

http://hackage.haskell.org/package/MHask

从 hackage 页面复制:

MHask 是

所在的类别
  • 对象是 Haskell 类型 (* → *),具有 Prelude.Monad
  • 的实例
  • 从对象 m 到对象 n 的箭头是 Haskell 形式的函数 (forall x.m x → n x)
  • 箭头组合只是Haskell函数组合的特化
  • 对象m的恒等箭头是Haskell中的Prelude.id函数,专用于(forall x.m x → m x)

买者自负;我已经很久没有看过这个了。可能有错误。

加布里埃尔·冈萨雷斯 (Gabriel Gonzalez) 已就此发表博客。这是一个 post: http://www.haskellforall.com/2012/08/the-category-design-pattern.html

里面,他调用了Hask "the function category",还讨论了"the Kleisli category"和"the pipes category."这些都是Haskell中Category类型类的实例实例。 Haskell 中的类别类型类是您可以在 Haskell 中找到的类别的子集。

Haskellalso form a category. The objects are the constraints, and the arrows mean "this constraint implies this other constraint" 中的约束。所以每个约束都暗示了它自己,在 Monad fApplicative f 之间、Ord aEq a 之间以及 Ord aOrd [a] 之间都有一个箭头。

是一个thin category,所以两个对象之间最多只有一个箭头。