haskell - 为什么静态箭头概括了箭头?

标签 haskell applicative category-theory arrows

众所周知,Applicative概括 Arrows .在 Idioms are oblivious, arrows are meticulous, monads are promiscuous Sam Lindley、Philip Wadler 和 Jeremy Yallop 的论文据说 Applicative等价于静态箭头,即具有以下同构的箭头:arr a b :<->: arr () (a -> b)据我所知,它可以通过以下方式说明:
注:newtype Identity a = Id { runId :: a } . Klesli Identity是一个静态箭头,因为它包裹着 k :: a -> Identity b .同构只是删除或添加包装器。Kleilsi Maybe不是静态箭头,因为 k = Kleisli (const Nothing)存在 - 所有 f :: a -> b s 对应于 Just . f ,并且没有 k 的位置在同构中。
但同时两者Kleisli IdentityKleisli MaybeArrow实例。因此,我看不出泛化是如何工作的。
Haskell/Understanding Arrows tutorialWikibooks他们say static morphismnote the following :

Those two concepts are usually known as static arrows and Kleisli arrows respectively. Since using the word "arrow" with two subtly different meanings would make this text horribly confusing, we opted for "morphism", which is a synonym for this alternative meaning.


这是我迄今为止唯一的线索 - 我是否混淆了 Haskell Arrow和箭头?
那么,这种层次结构是如何运作的呢?这是怎么回事Applicative的属性(property)形式化/证明?

最佳答案

我相信“概括”这个词会让你误入歧途。如 kArrow ,确实是这样:

  • k x对于任何 x将是 Applicative ;
  • 特别是k ()将是一个应用程序;
  • 然后可以将该应用程序重新旋转为等效的静态箭头(根据 Static from semigroupoidsStatic (k ()) a b ~ k () (a -> b) )

  • 然而,这个过程在一般情况下并不是无损的:静态箭头 Static (k ())不一定等同于 k我们开始的箭头;不需要同构。换句话说,静态箭头不能概括箭头。如果我们定义一个 StaticArrow类,它将是 Arrow 的子类,而不是父类(super class)。
    P.S.:在维基教科书的引文中,措辞只是一个强调问题。例如,虽然 Kleisli 箭头确实是 Hughes/Control.Arrow箭,大多数时候当人们谈论“Kleisli 箭”时,他们并不是在想 Arrow例如,但仅是关于它们如何是范畴中的态射,其中范畴律相当于某些 monad 的 monad 律。特别是,这足以构成维基教科书那一段中的讨论。

    关于haskell - 为什么静态箭头概括了箭头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62849399/

    相关文章:

    haskell - 使用重载字符串

    haskell - MaybeT m 的应用实例假设 Monad m

    javascript - JavaScript 中的仿函数实现

    c++ - 为什么具有无用的隔离 `static` 的函数被认为是不纯的?

    haskell - 没有 (Show ([(Char, Char)] -> Char)) 的实例

    Haskell:对于 Map 中的每个 (k,v),用 k 和 v 执行 IO()

    parsing - 如何在不假设 Monad 的情况下为解析器实现 Applicative 实例?

    haskell - 为什么 Applicative 应该是 Monad 的父类(super class)?

    haskell - Haskell 中的仿函数与范畴论中的仿函数有何关系?

    haskell - 如何定义签名为 h::M Int -> M Int -> M Int 的函数,以便 h (M x) (M y) = M (x+y) 而不解开 monad?