Data.Tuple impoverished

Henning Thielemann lemming at henning-thielemann.de
Fri Jun 15 14:48:21 CEST 2012


On Fri, 15 Jun 2012, Ivan Lazar Miljenovic wrote:

> On 15 June 2012 17:59, Andreas Abel <andreas.abel at ifi.lmu.de> wrote:
>> Hi,
>>
>> the module Data.Tuple offers a sad collection of 5 functions.  Many standard
>> functions are missing.  For instance, I'd expect all the functions of
>>
>>  Data.Tuple.HT  (package utility-th)
>>
>> to be part of Data.Tuple, which are
>>
>>  mapPair :: (a -> c, b -> d) -> (a, b) -> (c, d)
>>  mapFst :: (a -> c) -> (a, b) -> (c, b)
>>  mapSnd :: (b -> c) -> (a, b) -> (a, c)
>
> I believe these are covered by Control.Arrow...

Yes, they are covered by 'first', 'second' and '***'. But I decided to 
implement them in Data.Tuple.HT because I think that the use of the pair 
type in 'first' and friends is not the focus of the arrow functions. It 
would be easy for me to add mapFst3, mapSnd3.

>>  -- swap :: (a, b) -> (b, a)  -- swap is present in Data.Tuple

I have also added such functions in order to allow people to write code 
that works for many different GHC and 'base' versions.


>> P.S.: I have reimplemented all these functions for myself, because I use
>> them, but I am puzzled why they are not in the standard library.

You can import my package without having to regret. I promise not to add 
new dependencies and that it will remain Haskell 98.



More information about the Libraries mailing list