
On Sunday 28 November 2004 13:53, Keean Schupke wrote:
... here is an example object in actuall Haskell code using the HList library...
point = do x <- newIORef 0 returnIO $ mutableX .=. x .*. getX .=. readIORef x .*. moveD .=. (\d -> modifyIORef x ((+) d)) .*. emptyRecord
And here's the object in use:
myFirstOOP = do p <- point p # getX >>= print p # moveD $ 3 p # getX >>= print
As you can see no lifting or awkwardness involved... the syntax looks very much like the OCaml example it was ported from.
Very nice. This would be enough for single threaded programs and as long as the local state is simple. I think it would get quite awkward as soon as you want to provide - more mutable members - synchronized access + asynchronous methods (i.e. _reactive_ objects) I am ready to be proved wrong, though. Ben