bisequence
和 bitraverse
之间的关系时遇到了一些麻烦。根据文档,这是他们的签名:
bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)
bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)
另外根据文档,以下关系成立:
bisequence ≡ bitraverse id id
但这段关系对我来说没有意义:
id
的签名是a -> a
,那么它怎么能被接受为bitraverse
的第一个或第二个参数呢? a -> f c
?
就算我们克服了第一点,
bitraverse id id
的类型应该是Bitraversable t => t a b -> f (t c d)
吧?但这和bisequence
的类型不一样;稍后在输入中的a
和b
上缺少一个应用程序。
我错过了什么?我敢肯定这两个误解是相关的,因为它们都与类型中缺少应用层有关。