[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Continuing in the role as syntax czar:
From: fplangc-request@cs.ucl.ac.uk
Date: 11 Sep 91 19:11
Sender: Paul Hudak <hudak-paul@cs.yale.edu>
To: dswise@seafox.cs.indiana.edu
Cc: boutel-brian@cs.yale.edu, fplangc@cs.ucl.ac.uk
In-Reply-To: <David "S." Wise's message of Wed, 11 Sep 91 11:39:38 EST <199109111645.AA10034@eli.CS.YALE.edu>>
Subject: Continuing in the role as syntax czar:
Full-Name: Paul Hudak
....Then we also could apply them to functions on homogeneous tuples:
e.g. map 1 (1+) (0, 1, 2, 3) would be (1, 2, 3, 4)
Note that the tuple must be homogeneous. Here's how I would do this
in My Favorite Haskell (:-):
class Mapable (t a)
where map :: (a->b) -> t a -> t b
instance Mapable [a]
where map f [] = []
map f (x:xs) = f x : map f xs
instance Mapable (a,a)
where map f (x,y) = (f x, f y)
instance Mapable (a,a,a)
where map f (x,y,z) = (f x, f y, f z)
...etc.
-Paul