
Let me pick one example. Let's make a class that can convert between
tuples and lists.
Of course there are restriction when this works, but it can still be useful.
class TupleList t l | t -> l where
tupleToList :: t -> l
listToTuple :: l -> t
instance TupleList () [a] where
tupleToList () = []
listToTuple [] = ()
-- XXX This doesn't work, and is just wrong.
--instance TupleList (a) [a] where
-- tupleToList (a) = [a]
-- listToTuple [a] = (a)
instance TupleList (a,a) [a] where
tupleToList (a1,a2) = [a1, a2]
listToTuple [a1,a2] = (a1, a2)
instance TupleList (a,a,a) [a] where
tupleToList (a1,a2,a3) = [a1, a2, a3]
listToTuple [a1,a2,a3] = (a1, a2, a3)
On Fri, Oct 3, 2008 at 8:17 AM, Jason Dusek
Jason Dagit
wrote: Perhaps I am lacking in imagination, but I still can't see the value of one tuples. -- _jsn