Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 强闭函数的推广_Haskell_Functor_Category Theory_Profunctor - Fatal编程技术网

Haskell 强闭函数的推广

Haskell 强闭函数的推广,haskell,functor,category-theory,profunctor,Haskell,Functor,Category Theory,Profunctor,我看到的是强大而封闭的教授: 类Profunctor p,其中 dimap::(a'->a)->(b->b'->PAB->PAB'b' 类Profunctor p=>强p,其中 strong::pab->p(c,a)(c,b) 类Profunctor p=>Closed p其中 关闭::p a b->p(c->a)(c->b) ((,)是一个对称的双Functor,因此它相当于“proFunctor”包中的定义。) 我注意到(>)a和(,)a都是内函子。似乎Strong和Closed具有类似的

我看到的是强大而封闭的教授:

类Profunctor p,其中
dimap::(a'->a)->(b->b'->PAB->PAB'b'
类Profunctor p=>强p,其中
strong::pab->p(c,a)(c,b)
类Profunctor p=>Closed p其中
关闭::p a b->p(c->a)(c->b)
(,)
是一个对称的双Functor,因此它相当于“proFunctor”包中的定义。)

我注意到
(>)a
(,)a
都是内函子。似乎
Strong
Closed
具有类似的形式:

class(函子f,函数p)=>cfp其中
c::p a b->p(f a)(f b)
事实上,如果我们看看法律,有些法律也有类似的形式:

strong。坚强的≡ 联合国亚太经合组织协会。坚强的
关闭关闭≡ 迪玛咖喱。关闭
lmap(第一个f)。坚强的≡ rmap(第一个f)。坚强的
lmap(.f)。关闭≡ rmap(.f)。关闭

这些都是一般情况下的特殊情况吗?

非常有趣。这不是一个真正的答案,只是想法

因此,我们需要的是对
(,)
(>)
的抽象,它提供了
assoc
/
curry
first
/
precompose
的泛化。我将谈到前者:

class Isotropic f where
  lefty :: f a (f b c) -> f (a,b) c
  righty :: f (a,b) c -> f a (f b c)
  -- lefty ≡ righty⁻¹

instance Isotropic (,) where
  lefty (a,(b,c)) = ((a,b),c)
  righty ((a,b),c) = (a,(b,c))

instance Isotropic (->) where
  lefty = uncurry
  righty = curry
简单。问题是,还有其他这样的例子吗?当然还有一个小问题

newtype Biconst c a b = Biconst c

instance Isotropic (Biconst c) where
  lefty (Biconst c) = Biconst c
  righty (Biconst c) = Biconst c
然后是结果profunctor

class Profunctor p => Stubborn p where
  stubborn :: p a b -> p (Biconst d c a) (Biconst d c b)
还不如写下来

class Profunctor p => Stubborn p where
  stubborn :: p a b -> p d d
但这些例子似乎也太琐碎了,没有任何用处:

instance Stubborn (->) where
  stubborn _ = id
instance (Monad m) => Stubborn (Kleisli m) where
  stubborn (Kleisli _) = Kleisli pure
instance (Monoid m) => Stubborn (Forget m) where
  stubborn (Forget _) = Forget $ const mempty

我怀疑
(,)
(>)
确实是这方面唯一有用的案例,因为它们分别是“free bifunctor”/“free profunctor”。

您可以将
选项添加到列表中。
Strong
Choice
(或者Jeremy Gibbons称之为笛卡尔和共笛卡尔)都是Tambara模块的示例。我在上的博客文章(跳到讨论部分)中谈到了包含
关闭的
的一般模式,名字是
相关的

,我想在我的问题中指出
选择
,但“profunctors”包的文档已经说这是另一种力量概念,所以我把它省略了。无论如何,谢谢!