[Haskell-cafe] Newbie question: multi-methods in Haskell

2007-08-06 Thread peterv
In de book Modern C++ design, Andrei Alexandrescu writes that Haskell supports “multi-methods” http://books.google.com/books?id=aJ1av7UFBPwCpg=PA3ots=YPiJ_nWi6Ydq=moder n+C%2B%2Bsig=FWO6SVfIrgtCWifj9yYHj3bnplQ#PPA263,M1 How is this actually done in Haskell? Maybe this is just a basic feature of

Re: [Haskell-cafe] Newbie question: multi-methods in Haskell

2007-08-06 Thread Brian Hulley
peterv wrote: In de book Modern C++ design, Andrei Alexandrescu writes that Haskell supports “multi-methods” Using multi-methods, I could write (in pseudo code) collide (Asteroid, Planet) = an asteroid hit a planet collide (Asteroid, Earth) = the end of the dinos ... collide (Planet,

Re: [Haskell-cafe] Newbie question: multi-methods in Haskell

2007-08-06 Thread Dan Weston
Remember that type classes do not provide object-oriented functionality. The dispatch is static, not dynamic. Although OOP can be simulated in Haskell, it is not a natural idiom. If you need dynamic dispatch (including multiple dispatch), you may want to reconsider your solution. Dan Weston

Re: [Haskell-cafe] Newbie question: multi-methods in Haskell

2007-08-06 Thread Tillmann Rendel
peterv schrieb: In de book Modern C++ design, Andrei Alexandrescu writes that Haskell supports “multi-methods” http://books.google.com/books?id=aJ1av7UFBPwCpg=PA3ots=YPiJ_nWi6Ydq=moder n+C%2B%2Bsig=FWO6SVfIrgtCWifj9yYHj3bnplQ#PPA263,M1 Chapter 11, Page 263 of this books: The C++ virtual

Re: [Haskell-cafe] Newbie question: multi-methods in Haskell

2007-08-06 Thread Brian Hulley
Dan Weston wrote: Remember that type classes do not provide object-oriented functionality. The dispatch is static, not dynamic. Although OOP can be simulated in Haskell, it is not a natural idiom. If you need dynamic dispatch (including multiple dispatch), you may want to reconsider your

RE: [Haskell-cafe] Newbie question: multi-methods in Haskell

2007-08-06 Thread peterv
question: multi-methods in Haskell Dan Weston wrote: Remember that type classes do not provide object-oriented functionality. The dispatch is static, not dynamic. Although OOP can be simulated in Haskell, it is not a natural idiom. If you need dynamic dispatch (including multiple dispatch

Re: [Haskell-cafe] Newbie question: multi-methods in Haskell

2007-08-06 Thread Brian Hulley
peterv wrote: This is very nice, but it does not really solve the original problem. To get Haskell to choose the best fit it's necessary to encode the location of each element in the hierarchy, so that elements deeper in the hierarchy are more instantiated than those at the top. Then