[Haskell-cafe] mapFst and mapSnd

Benjamin Edwards edwards.benj at gmail.com
Tue May 28 11:00:01 CEST 2013


You might want to look at the arrow type class and the instance for (->).

Ben
On 28 May 2013 09:56, "Dominique Devriese" <
dominique.devriese at cs.kuleuven.be> 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
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130528/9fbdcf8a/attachment.htm>


More information about the Haskell-Cafe mailing list