我一直在读"“一书,我停止了这个例子: bimap :: (a -> b) -> (c -> d) -> p a c -> p b d-- (9, 11)λ second (*2) (3, 5) -- (3, 10)instance Bifunctorarguments to ‘(x, y)’
Expected kind ‘* -> * -> *’,
哈斯克尔的Data.Bifunctor基本上是: bimap :: (a -> c) -> (b -> d) -> f a b -> f c d class Bifunctor f => Biapplicative f where biap :: f (a -> b) (c --> y -> z) -> f a x -> f
bifunctors库公开了以下数据类型:正如在库中所看到的,如果Biff p f g a是Bifunctor,g是Functor,那么p就是Bifunctor。instance (Bifunctor p, Functor g) => Functor (Biff p f g a) where
fmap f = Biff . second (fmap f) .
我在尝试实现映射类(Bifunctor[Map[_, _]])时偶然发现了这个问题。在猫中是这样定义的: * The quintessential method of the Bifunctor trait, it applies a
* function to each"side" of the bifunctor
我有以下关于monoidal类别类的定义(类似于标准库,但提供了必要的自然同构的逆): bimap :: r a b -> s c d -> t (p a c) (p b d)class (Bifunctorassociate :: k (b (b x y) z) (b x (b y z))
associa
知道像ListF和TreeF这样的类型是双函子,到目前为止,我已经得到了以下内容:import Data.BifunctorBifunctor f => (a -> b) -> Fix (f a) -> Fix (f b) where在Haskell中,这会给出以下错误:Could not deduce (Functor (f a)) arising from a