ekmett / bifunctors

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

Applicative Tannen #86

Open Icelandjack opened 3 years ago

Icelandjack commented 3 years ago

I forgot if I've brought this up before, should this instance exist?

instance (Applicative f, Biapplicative bi, Monoid a) => Applicative (Tannen f bi a) where
 pure :: b -> Tannen f bi a b
 pure b = Tannen do
  pure (bipure mempty b)

 liftA2 :: (b1 -> b2 -> b3) -> (Tannen f bi a b1 -> Tannen f bi a b2 -> Tannen f bi a b3)
 liftA2 (·) (Tannen as) (Tannen bs) = Tannen do
  liftA2 (biliftA2 (<>) (·)) as bs