ekmett / bifunctors

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

Add functions from Biff to Sum/Product/Lift #54

Open Icelandjack opened 7 years ago

Icelandjack commented 7 years ago

Are any of these (/ inverses) useful

toSum :: Biff Either f g a a -> Sum f g a
toSum (Biff (Left  fa)) = InL fa
toSum (Biff (Right ga)) = InR ga

toProduct :: Biff (,) f g a a -> Product f g a
toProduct (Biff (fa, ga)) = Pair fa ga

-- transformers
toLift :: Biff Either Identity g a a -> Lift g a
toLift (Biff (Left (Identity a))) = Pure  a
toLift (Biff (Right ga))          = Other ga