Jannis
03/25/2019, 2:28 PM(a -> b) -> (c -> d) -> p a c -> p b d and arrow fun <A, B, C, D> Kind2<F, A, B>.bimap(fl: (A) -> C, fr: (B) -> D): Kind2<F, C, D>. So the intuition is its basically a functor applied to both type arguments. Fold looks more like this (for option): (() -> b) -> (a -> B) -> Maybe a -> b fun <A, B>Option<A>.fold(none: () -> B, some: (A) -> B): B and either is similar. Fold destructures while bimap keeps structure. If you are looking for types that are bifunctors and their uses: Either has a bifunctor instance, Ior should have one and I think soon we'll have IO be parameterized to IO<E, A> and that should be a bifunctor as wellkioba
03/25/2019, 4:46 PMbimap is similar to map with the capability to give a Left?
Thank you for the arrow solution! haskell is way different and takes time to translate to kotlin, for me at lest 🙂Jannis
03/25/2019, 5:09 PMLeft but for either and ior that is correct. For example `Tuple2`/`Pair` and Const have a Bifunctor instance as well. (Not sure if they do in arrow, but they should!). I kind of just think of it as a functor that applies to the second typeparameter, whereas the normal functor instance prefers one. The Functor bit is important here as similar laws apply for Bifunctor. I'd suggest looking at the laws to understand what qualifies as a `Bifunctor`/`Functor` instance.kioba
03/25/2019, 6:38 PMJannis
03/25/2019, 7:25 PMJannis
03/25/2019, 7:26 PM