
21 Oct
2007
21 Oct
'07
11:39 p.m.
TJ:
After all, sometimes all you need to know about a list is that all the elements support a common set of operations. If I'm implementing a 3d renderer for example, I'd like to have
class Renderable a where render :: a -> RasterImage
scene :: Renderable a => [a]
Everyone has launched into explanations of how to use existentials to do this, but you may be happy in just haskell 98. In the above, you could just have: scene :: [RasterImage] Laziness will ensure that the computation/storage of the images will not occur until they are used. Tim