M F*_*yck 9 haskell functor category-theory profunctor
我当时正在研究强壮的和封闭的专业人士:
class Profunctor p where
dimap :: (a' -> a) -> (b -> b') -> p a b -> p a' b'
class Profunctor p => Strong p where
strong :: p a b -> p (c, a) (c, b)
class Profunctor p => Closed p where
closed :: p a b -> p (c -> a) (c -> b)
Run Code Online (Sandbox Code Playgroud)
((,)是对称bifunctor,因此它等效于“ profunctors”包中的定义。)
我注意到这两个(->) a和(,) a是endofunctors。似乎Strong并Closed具有类似的形式:
class (Functor f, Profunctor p) => C f p where
c :: p a b -> p (f a) (f b)
Run Code Online (Sandbox Code Playgroud)
确实,如果我们看法律,有些法律也有类似的形式:
strong . strong ? dimap unassoc assoc . strong
closed . closed ? dimap uncurry curry . closed
lmap (first f) . strong ? rmap (first f) . strong
lmap (. f) . closed ? rmap (. f) . closed
Run Code Online (Sandbox Code Playgroud)
这些都是一般情况下的特例吗?
您可以添加Choice到列表中。两者Strong和Choice(或笛卡尔和cocartesian,如杰里米长臂猿调用它们)是Tambara模块的例子。我谈论了Closed在我的关于profunctor 光学的博客文章中包含的一般模式(跳到讨论部分),在名称下Related。