Haskell 高阶可遍历函子是否有相应的光学性质?

Haskell 高阶可遍历函子是否有相应的光学性质?,haskell,haskell-lens,category-theory,traversable,haskell-hedgehog,Haskell,Haskell Lens,Category Theory,Traversable,Haskell Hedgehog,具有如下定义的HTraversable类: -- | Higher-order traversable functors. -- class HTraversable t where htraverse :: Applicative f => (forall a. g a -> f (h a)) -> t g -> f (t h) 它与它们的类型一起使用,用于根据值是具体的还是抽象的来参数化类型t有kind(*->*)->*并且是一个高阶函子,尽管它们实际上没有那个

具有如下定义的
HTraversable
类:

-- | Higher-order traversable functors.
--
class HTraversable t where
  htraverse :: Applicative f => (forall a. g a -> f (h a)) -> t g -> f (t h)
它与它们的类型一起使用,用于根据值是具体的还是抽象的来参数化类型
t
有kind
(*->*)->*
并且是一个高阶函子,尽管它们实际上没有那个类,
f
g
h
有kind
*->*
。我在几个不同的库中看到了相同的定义

有没有办法从中获得一个光学元件?我承认我甚至不知道那会做什么,而且我对镜头或常规的
可遍历的
也不太舒服。

当然

type HTraversal s t a b =
    forall f. Applicative f => (forall x. a x -> f (b x)) -> s -> f t

htraverse :: HTraversable t => HTraversal (t a) (t b) a b
请记住,
lens
遍历
是通过采用
遍历
的类型,并让
ta
tb
类型发生变化来实现的,将可遍历对象视为一个整体blob而不是多态容器


我不知道HTraversal有多有用。你不能用
(.)

嗯,很有趣。所以有一个对应的东西,但它并不适合其他光学元件。我想知道是否有一组“高阶光学元件”可以使用。
HTraversable
用于从函子类别到Hask的函子类别中的对象。您可以使用函子类别上的内函子类别(例如monad transformers),对于它,
Traversable
看起来像
itraverse::Applicative f=>(forall x.a x->f(b x))->(forall x.s x->f(t x))
。这种类型的遍历确实由
()
组成,您也可以构建棱镜等。不过,无论是
HTraversable
还是
ITraversable
都不能与
lens
进行互操作,因为它们构建在不同的类别上。