Adding swap/compose functions to Data.Tuple and Data.Function
Edward Kmett
ekmett at gmail.com
Tue Nov 20 20:23:26 CET 2012
On Tue, Nov 20, 2012 at 2:14 PM, John Wiegley <johnw at fpcomplete.com> wrote:
> Moving discussion from http://hackage.haskell.org/trac/ghc/ticket/7435:
>
> I propose adding the following three functions to Data.Tuple and
> Data.Function, respectively:
>
> swap :: (a,b) -> (b,a)
> swap = snd &&& fst
>
>
Data.Tuple already contains swap.
Fairly obvious, but strangely missing.
>
> compose :: [(a -> a)] -> a -> a
> compose = foldr (.) id
>
> composeM :: [(a -> m a)] -> a -> m a
> composeM = foldr (<=<) return
>
I would actually consider these to fall beneath the "Fairbairn threshold".
The composition of them is obvious, and the suggested names already exist
commonly in a lot of third party code for all sorts of purposes.
The pain of adoption plus the annoyance of trying to find them exceeds, to
me, the utility of adding them.
-Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20121120/bf6d2d82/attachment.htm>
More information about the Libraries
mailing list