Tue Jul 19 18:14:35 CEST 2011


In this:

  f x = do
    x2 <- square (1 + x)
    x4 <- square (1 + x2)
    square x4

it's impossible to do:

  square (square (1 + square (1 + x)))

because of types!  So sharing propagates; it is mandatory.  A
computatin with sharing information will never be able to take the
place of one without sharing, but conversely it's straightforward to
inject pure computations into the sharing monad.

So what makes this a sharing monad?  Internally, it's a much more
powerful state-continuation monad, but the limited amount of
operations made available limit the effects.  If the implementation of
the monad is kept hidden (no constructors) then there are only 2
abstract constructors: the default "return" and the "returnN" sharing

Because the monad type "protects" the output value in such a way that
only the bind operator can access it, all composition logic can be
incorporated in bind itself, and there is no way the high-level
sharing behaviour can be violated once it is attached, meaning once a
type is wrapped in a monad.

A monadic value is completely opaque, with the only promise that it
has burried inside of it a certain type that can be fished out by