简体   繁体   English

如何将一个 comonad 和一个 monad 组合成一个 comonad?

[英]How to combine a comonad and a monad into a comonad?

Assume I have假设我有

  • a comonad D共同点D
  • a monad T单子T
  • a distributive law l: DT -> TD of the comonad D over the monad T .分配律l: DT -> TD是 comonad D在 monad T上的。

How can I define the comonad DT ?如何定义 comonad DT

You can't.你不能。 Suppose D is the identity comonad and T is Cont Void , ie the continuation monad at the empty type.假设D是 identity comonad, TCont Void ,即空类型的延续 monad。

newtype D a = D {runD :: a}
newtype T a = T {runT :: (a -> Void) -> Void}

Then distributivity holds trivially.那么分配性是微不足道的。 But extract:: D (T a) -> a is not definable as a total computable program.但是extract:: D (T a) -> a不能定义为一个完整的可计算程序。 It would be double negation elimination forall a. ((a -> Void) -> Void) -> a这将是对forall a. ((a -> Void) -> Void) -> a forall a. ((a -> Void) -> Void) -> a , which is not definable in constructive languages. forall a. ((a -> Void) -> Void) -> a ,这在构造性语言中是不可定义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM