What about tuple accessor function for (,,) ... ?
Marc Weber
marco-oweber at gmx.de
Wed Apr 25 09:05:18 EDT 2007
There is a fst and a snd function.
What about
fstOf3 ( \(x,_,_) -> x )
sndOf3 ( \(_,x,_) -> x )
thrdOf3 ( \(_,_,x) -> x )
?
...
or using overloading ?
fst
snd
thrd
_4th
_5th
I think its easier to type/ read than \(_,_,x,_) -> x
class Second a b | a -> b where
t2 :: a -> b
instance Second (a,b) b where t2 (a,b) = b
instance Second (a,b,c) b where t2 (a,b,c) = b
instance Second (a,b,c,d) b where t2 (a,b,c,d) = b
instance Second (a,b,c,d,e) b where t2 (a,b,c,d,e) = b
Or is there any drawback I didn't see?
I'd like to see them in Data.Tuple
Marc
More information about the Libraries
mailing list