[Haskell-beginners] Designing complex Haskell programs
Bob Ippolito
bob at redivi.com
Fri Jan 3 17:16:28 UTC 2014
Generally speaking, state lives on the call stack in functional programming
languages that have tail call elimination. Modification of the state is
done by recursion with a new value for the state. This is more or less
equivalent to a "do while" loop in imperative programming.
myServer :: State -> IO ()
myServer state = do
state' <- updateState state
myServer state'
For the concurrency, Control.Concurrent or Cloud Haskell (for a higher
level Erlang-like approach) is probably the way to go here. Parallel and
Concurrent Programming in Haskell is a great resource:
http://chimera.labs.oreilly.com/books/1230000000929
On Fri, Jan 3, 2014 at 8:45 AM, Courtney Robinson <courtney at crlog.info>wrote:
> I'm trying to take the training wheels of and moving more of my code base
> to Haskell from C++ but finding it increasingly tricky.
>
> I have a subset of a gossip protocol written in C++.
> When a server comes online it connects to 1 or more nodes already in the
> cluster and get data from them about other nodes they know of.
>
> The new node merges the information and keeps a copy of the merged view.
> Every so often it contacts the nodes it knows about and refreshes the
> merged view. It also must have the up to date view ready to be sent in
> response to a new node joining.
>
> I currently can't wrap my head around how to maintain this state. How
> would a more experienced Haskeller approach this problem? Code is OK if it
> demonstrates a particular point but I'm more interested in the line of
> thought that would go into designing a solution as I suspect that'll be
> more useful as I get further into the migration.
>
> As a gauge to you for my current level in Haskell. I read and understand
> most Haskell programs fine. I write some but currently heavily rely on
> hackage/hoogle docs for APIs, even some common ones.
>
> Thanks
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140103/86f9e21c/attachment.html>
More information about the Beginners
mailing list