RFC functions for sums and products
I'll ask on the libraries mailing list depending on feedback.
Adding these to Data.Functor.Sum
, Data.Functor.Product
a la Control.Arrow
(||||) :: (f a -> b) -> (g a -> b) -> ((Sum f g) a -> b)
f |||| g = \case
InL fa -> f fa
InR ga -> g ga
(&&&&) :: (a -> f b) -> (a -> g b) -> (a -> (Product f g) b)
(f &&&& g) a = f a `Pair` g a
||||
is used in "Monad transformers and modular algebraic effects: What binds them together" in section 2.4, the names are up for discussion
- *Edit**: coproduct is one name for
||||