Data.Functor.{Product,Sum} functions

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Sat Dec 24 10:06:20 UTC 2016


Baldur Blöndal <baldurpet at gmail.com> writes:

> Let's see if any of these are useful (a lot more at
> https://ghc.haskell.org/trac/ghc/ticket/13026)
>
> (||||) :: (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
>
> I couldn't think of any for Data.Functor.Compose, names are up for
> bikeshedding

I don’t have any particular preference for names, but I’d say
that any name consisting of more than three consecutive
identical symbols is going to be too hard to read (particularly
if the symbol is “|”). There’s a whole unicode alphabet out
there.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk



More information about the Libraries mailing list