Eric wrote: > (1) Have Handlers implement a method handle(m: Msg). To add new types of > message, we declare message types which extend Msg. The Handler then > uses runtime type testing to decide how to deal with each message. The > advantage of this design is that we can add new Handler and new Msg > types without recompiling the Dispatcher.
Note however that the type of the handle method is a lie (your handlers don't actually accept arbitrary messages). I guess, you actually want a polymorphic "Dispatcher", which will actually turn out to be a function. Of course, you give insufficient information to actually solve your problem. > Type classes allow us to adopt approach (0) in Haskell, but don't seem > to allow approach (1).... I consider that a good thing. -Udo
signature.asc
Description: Digital signature
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe