ekmett / bifunctors

Haskell 98 bifunctors, bifoldables and bitraversables
Other
57 stars 42 forks source link

Add Applicative instance for Biff #83

Open masaeedu opened 4 years ago

treeowl commented 3 years ago

This seems a bit arbitrary to me. Couldn't you write a Data.Functor.Compose-like instance like this?

instance (Applicative (p (f a)), Applicative g) => Applicative (Biff p f g a) where
  pure = Biff . pure . pure
  liftA2 f (Biff xs) (Biff ys) = Biff $ liftA2 (liftA2 f) xs ys

I'm not saying we should do this, but it's not at all obvious that the limited instance you suggest is the right one, if there is a right one.