On 10/22/07, Tim Docker <[EMAIL PROTECTED]> wrote:
> 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
>

Ah... indeed it can, in this case. It won't work if class Renderable
also has a method for saving to file, etc, I suppose, unless scene ::
[(RasterImage,IO (),...whatever other operations...)]

Thanks for the heads up :)

TJ
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to