hyperthunk/distributed-process-platform — pull request #13 by rodlogic (2012-11-22 03:50:42+00:00)
Title: Introduced a Server monad to wrap the server state

The code compiles and runs. See the updated Counter.hs file for a simple example.

Server handlers are now implemented in terms of a Server monad, which wraps the Process monad. The state can be manipulated using the helper functions: getState, putState, modifyState.

E.g., the following implements the Counter server:

```haskell
handleCounter IncrementCounter = do
modifyState (+1)
return $ CallOk (CounterIncremented)

handleCounter GetCount = do
count <- getState
return $ CallOk (Count count)

handleReset ResetCount = do
putState 0
return $ CastOk
```

The inferred signatures for the counter services would be something like:
```haskell
handleCounter :: CounterRequest -> Server Int (CallResult CounterResponse)
handleReset :: CountReset -> Server Int CastResult

-- based on GenServer's handlers:
type CallHandler s a b = a -> Server s (CallResult b)
type CastHandler s a = a -> Server s CastResult
```

Still lots of small todos such as the proper termination, handling of timeouts, and handling of all InitResult, CallResult, CastResult.

No attention has been paid so far to proper file/code formatting, documentation or even more idiomatic Haskell code.