Modelling Java Interfaces with Existential data types

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
7651
Age (days ago)
7651
Last active (days ago)
0 comments
1 participants
participants (1)
-
Tom Pledger