hmemcpy / milewski-ctfp-pdf

Bartosz Milewski's 'Category Theory for Programmers' unofficial PDF and LaTeX source
https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/
Other
10.88k stars 578 forks source link

Possible error in bimap signature #188

Closed MazeChaZer closed 5 years ago

MazeChaZer commented 5 years ago

Version: v1.2.1

So in chapter 8.3 “Functorial Algebraic Data Types” the type signature of bimap in the instance of BiComp bf fu gu is given as

bimap :: (fu a -> fu a') -> (gu b -> gu b')
-> bf (fu a) (gu b) -> bf (fu a') (gu b')

I might be very well mistaken, but shouldn't that signature be like this?

bimap :: (a -> a') -> (b -> b')
-> bf (fu a) (gu b) -> bf (fu a') (gu b')

Especially because f1 and f2 are defined with exactly these signatures, a -> a' and b -> b' a few lines above.

Looking at the definition of the type class Bifunctor leads me to the same conclusion:

class Bifunctor (p :: * -> * -> *) where
    bimap :: (a -> b) -> (c -> d) -> p a c -> p b d

Thanks in advance for your feedback and sorry if I got confused and mixed things up :see_no_evil:

MazeChaZer commented 5 years ago

Nevermind me, I think the given type signature for bimap was meant to be for the type bf, not BiComp, closing.