<trb@eastpac.com.au> writes:
S.D.Mechveliani writes:
As Haskell has the standard functions fst, snd to decompose (a,b), maybe, it worths to provide also [...]
I've found some of these useful, except I named them differently:
fst3 :: (a,b,c) -> a snd3 :: (a,b,c) -> b thd3 :: (a,b,c) -> c
.... never got around to quadruples etc.
I'd like a general 'nth', but of course that would restrict us to monotyped tuples (e.g., nth :: Int -> (a,a,...,a,a) -> a ) This isn't possible to do more generally with some language extension, is it? A better way might be to define classes: class TwoTuple t a b | t -> a b where fst :: t -> a snd :: t -> b instance TwoTuple (a,b) where ... class (TwoTuple t) => ThreeTuple t c | t -> c where thd :: t -> c instance TwoTuple (a,b,c) where ... instance ThreeTuple (a,b,c) where ... --and so on. Quite verbose, but avoids the need to tag the functions with the tuple size. -kzm -- If I haven't seen further, it is by standing in the footprints of giants