These are present in Control.Arrow as (***), first and second respectively.
They are easy to overlook because they work for *all* arrows, not just
functions. So the type signatures look like:
first :: Arrow a => a b c -> a (b, d) (c, d)
If you replace a with (->), you'll see that this is exactly like your
mapFst.
On Tue, May 28, 2013 at 1:54 AM, Dominique Devriese <
[email protected]> wrote:
> Hi all,
>
> I often find myself needing the following definitions:
>
> mapPair :: (a -> b) -> (c -> d) -> (a,c) -> (b,d)
> mapPair f g (x,y) = (f x, g y)
>
> mapFst :: (a -> b) -> (a,c) -> (b,c)
> mapFst f = mapPair f id
>
> mapSnd :: (b -> c) -> (a,b) -> (a,c)
> mapSnd = mapPair id
>
> But they seem missing from the prelude and Hoogle or Hayoo only turn
> up versions of them in packages like scion or fgl. Has anyone else
> felt the need for these functions? Am I missing some generalisation
> of them perhaps?
>
> Regards,
> Dominique
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe