[Haskell-beginners] Are tuples really needed?

Peter Hall peter.hall at memorphic.com
Tue Aug 28 06:45:20 CEST 2012


They are just syntactic sugar. You can just as easily create your own
tuple types:

data Tuple2 a b = Tuple2 a b
data Tuple3 a b c = Tuple3 a b c
data Tuple4 a b c d = Tuple4 a b c d
..etc

...except it's pretty ugly and none of the built-in Prelude functions
that use tuples will work with them (curry, uncurry, fst, snd, lookup,
zip,..).

Peter


On 28 August 2012 02:47, Carlos J. G. Duarte
<carlos.j.g.duarte at gmail.com> wrote:
> Sorry if this question is too insane, but I was wondering if tuples are
> really needed in Haskell. I mean, could tuples be generally replaced by
> variables unroll (f x y z) and explicit data types, or are there some things
> only possible to do via tuples?
>
> Thx in advance (and sorry if this looks silly).
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



More information about the Beginners mailing list