[Haskell-cafe] Yet Another Haskell Tutorial Question

Bill Mill bill.mill at gmail.com
Wed Oct 11 21:16:57 EDT 2006

I've been working through the "Yet Anther Haskell Tutorial" at
http://www.cs.utah.edu/~hal/docs/daume02yaht.pdf , and I've gotten up
to Excercise 4.6. It says:

=== YAHT ===
Write a datatype Tuple which can hold one, two, three or four elements,
depending on the constructor (that is, there should be four
constructors, one for each
number of arguments). Also provide functions tuple1 through tuple4 which take a
tuple and return Just the value in that position, or Nothing if the
number is invalid
(i.e., you ask for the tuple4 on a tuple holding only two elements).
=== /YAHT ===

I've got a brute-force answer, but I'm sure that there's a
better way, and I can't find it. The code I've currently got is at
http://paste.lisp.org/display/27806 .

Anybody want to point me in the right direction?

Bill Mill
bill.mill at gmail.com

More information about the Haskell-Cafe mailing list