"arr fst"如何自然转变? [英] How is `arr fst` a natural transformation?

查看:114
本文介绍了"arr fst"如何自然转变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不久前我问了这个问题.关于以下箭头法则:

I asked this question a while ago. It was about the following arrow law:

arr fst . first f = f . arr fst -- (.) :: Category k => k b c -> k a b -> k a c

在帖子 Asad Saeeduddin 下的评论中,它以自然转化的方式对其进行了解释. >.我想检查一下我的理解是否正确,并将其与 Bartosz Milewski的进行比较有关自然转化的文章.

In the comments under the post Asad Saeeduddin explained it in terms of natural transformations. I would like to check whether I got their explanation right and compare it a bit to Bartosz Milewski's article on natural transformations.

因此,自然变换的定义是:

我们有两个类别CD和函子F, G : C ~> D.自然变换αD中的一族箭头,例如:

We have two categories C and D and functors F, G : C ~> D. A natural transformation α is a family of arrows in D such that:

  1. 这些箭头从F的结果转到G的结果.也就是说,对于C中的每个对象a,都有一个箭头(在a 处称为α组件)α_a :: F a ~> G a.
  2. 对于每个f :: a ~> bab作为C中的对象,保持:Gf . α_a = α_b . Ff.那是自然.
  1. These arrows go from the results of F to the results of G. That is, for every object a in C there exists an arrow (called the component of α at a) α_a :: F a ~> G a.
  2. For every f :: a ~> b, a and b being objects in C, holds: Gf . α_a = α_b . Ff. That is the naturality.

基本上,我们需要弄清楚我们的情况中有四个变量:CDFG.

Basically, we need to figure what four variables are in our case: C, D, F and G.

据我所知:

  • CD是任意类型的同一类别,其中k a b是其中的箭头,其中k是我们正在使用的Arrow实例.因此,FG是终结符.

  • C and D are the same category of arbitrary types, k a b being arrows in it, where k is the Arrow instance we are working with. Therefore, F and G are endofunctors.

F(, c)GIdentity.换句话说,如果我们不再使用类型,则将Ffirst映射,将Gid映射. 可能更容易地根据类型进行思考,因为CategoryArrow类可帮助我们构造类别的箭头,而不是对象

F is (, c) and G is Identity. In other words, if we no longer work with types, we map F with first and G with id. It would probably be easier NOT to think in terms of types as the Category and Arrow classes help us construct category's arrows, not objects

这是对的吗

此外, Bartosz Milewski写下了这些想法像这样:

fmap f . alpha = alpha . fmap f

据我所知,我们需要一种更通用的形式来实现我们的目的,因为alpha :: forall a. F a -> G a在这里仅针对其适用的类别来处理 Hask .还是我错了? fmap在这张照片中有哪个地方?

As far as I get it, we need a more general form for our purposes as here alpha :: forall a. F a -> G a deals with Hask only as the category it works with. Or am I wrong? Which place does fmap have in this picture?

推荐答案

您无需担心额外的类别,因为arr fst并不涉及任意的Arrow,只需涉及它的(,)实例即可.

You don't need to worry about extra categories, because arr fst doesn't involve an arbitrary Arrow, just the (,) instance of it.

在Haskell中,某些函子fc的类型为f a -> g a的函数是自然转换.对于arr fst :: (b -> c) -> (b, c),让f ~ (->) bg ~ (,) b.

In Haskell, a function of type f a -> g a for some functors f and c is a natural transformation. In the case of arr fst :: (b -> c) -> (b, c), let f ~ (->) b and g ~ (,) b.

这篇关于"arr fst"如何自然转变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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