[Haskell-cafe] run-time type testing in haskell?
Neil Mitchell
ndmitchell at gmail.com
Sat Apr 28 10:05:55 EDT 2007
Hi Eric
> I thought about that. But consider the following scenario. We have a
> Dispatcher and a Handler. The Dispatcher sends messages to Handlers.
> There are two ways we could implement this in an OOP language
"Consider how to implement OO features in Haskell"...
Lets not, rather instead lets try to come up with a much cleaner and
more Haskell-like by design. You can do imperative programming and OO
programming in Haskell, in the same way you can do functional
programming in ASM - possible but not a great idea. Thinking in
Haskell requires you to peel away all the layers of OO, right back to
the original thoughts about what you want to happen.
Rather than sending a message from the dispatcher to the handler, and
have a general purpose handler, why not instead register functions as
callbacks?
registerOnClick :: (Coordinates -> IO ()) -> IO ()
registerOnClose :: (Bool -> IO()) -> IO ()
Now you have absolutely no restriction on what information a "message" contains.
(Note: you haven't given enough information to know if this suits your
problem, but dynamic typing isn't the best answer, whatever the
question!)
Thanks
Neil
More information about the Haskell-Cafe
mailing list