是所有可区分类型Monads [英] Are all differentiable types Monads

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

问题描述

给定可区分类型,我们知道 Zipper 是一个 Comonad 。对此,丹·伯顿问道:如果派生出一个共同点,那么这是否意味着整合成了一个单子?或者说这是无稽之谈?。我想给这个问题一个具体的含义。 如果一个类型是可区​​分的,它是否必然是一个monad?这个问题的一个表述是询问,给定以下定义

  data Zipper ta = Zipper {diff :: D ta,here :: a} 

导出实例Diff t => Functor(Zipper t)

class(Functor t,Functor(D t))=> Diff t其中
type D t :: * - > *
up ::拉链t a - > t a
down:t a - >我们可以写出类似于

的签名的函数吗?我们可以写一些类似于>的签名的函数吗?

  return ::(Diff t)=> a  - > t a 
(>> =)::(Diff t)=> t a - > (a - > t b) - > tb

服从 Monad laws



链接的问题,有两种成功的方法来解决为 Zipper 派生 Comonad 实例的类似问题。第一种方法是展开 Diff 类以包含>> = 并使用偏分化。第二种方法是要求该类型是两次或无限可区分

解决方案

没有。 void functor data V a 是可区分的,但是 return 无法实现。


Given a differentiable type, we know that its Zipper is a Comonad. In response to this, Dan Burton asked, "If derivation makes a comonad, does that mean that integration makes a monad? Or is that nonsense?". I'd like to give this question a specific meaning. If a type is differentiable, is it necessarily a monad? One formulation of the question would be to ask, given the following definitions

data Zipper t a = Zipper { diff :: D t a, here :: a }

deriving instance Diff t => Functor (Zipper t)

class (Functor t, Functor (D t)) => Diff t where
    type D t :: * -> *
    up :: Zipper t a -> t a
    down :: t a -> t (Zipper t a)

can we write functions with signatures similar to

return :: (Diff t) => a -> t a
(>>=) :: (Diff t) => t a -> (a -> t b) -> t b

obeying the Monad laws.

In the answers to the linked questions, there were two successful approaches to a similar problem of deriving Comonad instances for the Zipper. The first approach was to expand the Diff class to include the dual of >>= and use partial differentiation. The second approach was to require that the type be twice or infinitely differentiable.

解决方案

No. The void functor data V a is differentiable, but return cannot be implemented for it.

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

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