
17 May
2010
17 May
'10
11:31 p.m.
On 05/17/10 23:21, haskell@lonely-star.org wrote:
So I guess, it comes down to the questions: How would you model the scenario described above in haskell?
how about, data Position = Position { positionX :: Float, positionY :: Float } move :: Position -> (Float, Float) -> Position data Spaceship = Spaceship Position ...other data members... data Rocket = Rocket Position ...other data members... (or perhaps not separate data-types but rather data SpaceThing = Spaceship { spacePosition :: Position, ...other data members...} | Rocket { spacePosition :: Position, ...other data members...} ... -- this latter has advantages and disadvantages regarding code reuse and code reliability. Experiment! -Isaac