Proposal: Add &&& and *** to Data.Tuple

Jon Fairbairn jon.fairbairn at
Mon Sep 17 14:47:33 EDT 2007

Ian Lynagh <igloo at> writes:

> On Mon, Sep 17, 2007 at 03:23:46PM +0200, Josef Svenningsson wrote:
>> It is becoming increasingly popular to import Control.Arrow just to
>> get access to the functions &&& and *** specialized to the function
>> arrow. I propose to add the specialized version of these two functions
> I think that having the same function with different types is likely to
> cause user confusion, and also ambiguous function errors.
> (I also think that using a different name for the specialised versions
> would be a bad idea.)

This seems to be a recurrent problem, and I keep wondering
whether there might not be a general solution along the
lines of declaring that an instance of a class at a
particular type subsumes the functions declared with those
names at the specialised type. Taking the current example, in Data.Tuple
there'd be

(***):: (b->c)->(b'->c')->(b,b')->(c,c')
(&&&):: (b->c)->(b->c')->b->(c,c')
f *** g = ...
f &&& g = ...

and in Control.Arrow there'd be

class Arrow a where 
   (***):: a b c -> a b' c' -> a (b, b') (c, c')
   (&&&):: a b c -> a b c' -> a b (c, c')


instance Arrow (->) where
   (***) subsumes (Data.Tuple.***)
   (&&&) subsumes (Data.Tuple.&&&)

the effect (and type checks) within the Arrow module would
be the same as 

import qualified Data.Tuple ((***),(&&&))

instance Arrow (->) where
   (***) = (Data.Tuple.***)
   (&&&) = (Data.Tuple.&&&)

and modules that imported only Arrow (not Tuple) would see
no difference from the present state of affairs.  Where
things would be different would be if a module imported both
Tuple and Arrow, when, instead of a name clash, *** and &&&
would get their Arrow meanings (albeit with a specialised
instance for ->).

So if someone wrote a module that used only Tuple but later
needed to import Arrow, nothing untoward would happen -- no
renaming or complicated import hidings would be needed.  I
suppose one could describe this as shadowing of names with
the restriction that the shadowed name has to fit the shadow

[I have no attachment to the syntax suggested above]

Jón Fairbairn                                 Jon.Fairbairn at

More information about the Libraries mailing list