
22 Oct
2007
22 Oct
'07
5:26 a.m.
TJ:
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...)]
In this case I would generally create a record: data Renderable = Renderable { image :: RasterImage, saveToFile :: FilePath -> IO (), ... etc ... } scene :: [Renderable] You may then like to add a type class to turn things into renderables: class IsRenderable where toRenderable :: a -> Renderable instance IsRendeable Point where ... instance IsRenderable Line where ... It depends on your needs, but in my limited experience, records are often more convenient for emulating OO-style programming than are type classes. Tim