[Haskell-cafe] RE: Modelling Java Interfaces with Existential
data types
Mike Aizatsky
mm-aa at yandex.ru
Fri Jun 11 10:58:35 EDT 2004
Andre,
Thanks for paper pointers.
> Hmm, what's the higher goal of what you're trying to achieve? I, like
> you, came from a background of object-oriented programming, and I've
> always managed to avoid making a list containing more than one type
> after re-thinking about the problem. You can do it, sure, but the
> typical reasons for doing so in Haskell are very different from doing
> this in, say, Java.
I'm simulating the interaction of different physical entities with
particles. Basically I have this:
class PhysicalObject a where
interact1 :: a -> InteractionParameters -> InteractionResult
Also I have the Scene data structure, which has the list of physical
objects, read from a configuration file.
data Scene = Scene {....., objects :: [AnyPhysicalObject], ....}
The Scene is than passed to different simulation algorithms
type Simulator = Scene -> SimulationResult
All the simulators don't care about different PhysicalObjects. They are even
mostly pluggable. All simulator should know is the object interaction with
particles.
Regards,
Mike
More information about the Haskell-Cafe
mailing list