Jules Bean wrote:
A problem is the ability to pass callbacks to external libraries...
Why not just put all the state in a record, then there's only one thing to
pass around... you can use the state monad to hide this (or the state monad
transformer if you need to layer over IO) then use partial function application
to pass the necessary state to the callback on creation?
Also another take on the TWI question... Doesn't this equate to the same thing
as first class modules... then a module can be defined within the scope of a
function?
printablePoint x_init = do x <- newIORef x_init
return $ module PrintablePoint where getX = readIORef x ...
And the above can be seen as a model of an object... So using the HList library
you can write this:
class_printable_point x_init self = do x <- newIORef x_init returnIO $ mutableX .=. x .*. getX .=. readIORef x .*. moveD .=. (\d -> modifyIORef x ((+) d)) .*. ooprint .=. ((self # getX ) >>= print) .*. emptyRecord
Of course true top-level TWIs behave like static objects... But with dynamic objects you can guarantee that each object is only initialised once, but cannot guarantee that only one object of a given type exists (and I think encapsulation is a more important property than uniqueness).
Keean.
_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe