[Haskell-cafe] run-time type testing in haskell?
u.stenzel at web.de
Sat Apr 28 11:27:35 EDT 2007
> (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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070428/3254b3b4/attachment.bin
More information about the Haskell-Cafe