
8 Jun
2004
8 Jun
'04
10:33 p.m.
Hi. Another way is to take advantage of Haskell's laziness:
class Foo a where foo :: a -> Int
data Oof1 = Oof1 Int instance Foo Oof1 where foo (Oof1 i) = i
data Oof2 = Oof2 Int instance Foo Oof2 where foo (Oof2 i) = i
list1 = [foo (Oof1 10), foo (Oof2 20)]
That's all it takes. The applications of foo in list1 don't get evaluated until list1 is used, e.g. by sum. Regards, Tom