[Haskell-cafe] Execution Contexts

Benjamin Franksen benjamin.franksen at bessy.de
Sat Nov 27 15:03:13 EST 2004

On Saturday 27 November 2004 17:55, you wrote:
> A general point on top-level TWIs. It occurs to me that all variables
> are local to
> something (function, object, thread, process, machine, network,
> world...).
> [...]
> It seems to me the object model fits perfectly, and what people are
> trying to do is
> turn modules into primitive objects complete with data-hiding and
> constructors
> (top-level TWIs)... However modules cannot be nested so the model breaks
> down, and
> we end up needing first-class modules anyway.
> So in conclusion, it seems to me that that objects in Haskell solve all
> the problems
> that top-level TWIs solve, and still allow encapsulation and multiple
> 'process'
> contexts to be handled by the RTS. So use them!

Timber (formerly O'Haskell) has gone this way. Its object model is defined 
(and in fact was implemented) by a straight-forward translation into a 
(state) reader monad transformer over the IO monad. It is noteworthy that in 
this translation the (local) state of a Timber object is not a record but 
just an (IORef to an) anonymous tuple. [It is true that they added 'real' 
records and subtyping to the language but these additions are completely 
orthogonal to the object model. Records are merely used to group the monadic 
actions that define the interface of an object into a suitable type hierarchy 
(in order to model a weak form of interface inheritance).]

So, one of the things I learned when studying Timber's object model is that 
records (or modules) with mutable fields (and inheritance and so on) are 
*not* the whole story. The most interesting aspect is how objects react to 
external stimulus, i.e. their representation as monadic effects.

One *can* program in such a way in Haskell. What's missing is not so much 
records or first class modules, nor top-level IO actions (safe or not), but 
suitable syntactic sugar to alleviate the burden of having to lift (sic!) all 
IO actions to a suitable object/context monad.


More information about the Haskell-Cafe mailing list