[Haskell-cafe] Implementing a MUD server in haskell

Jack Kelly endgame.dos at gmail.com
Sat Dec 15 06:51:47 EST 2007


Hi,

I've been thinking about two things for some time now:
1. Sharpening my haskell
2. Implementing a MUD server
I've been thinking about doing (1) and (2) at the same time but I've run 
into some problems with data structures.

I need to be able to get a list of players from a room (for things like 
a 'look' command) and I need to be able to find which room contains a 
given player. I'm still looking at this problem through an imperative 
lens, so here's some sort-of-C:

struct room{
   ...
   struct player * players;
   ...
};

struct player{
   ...
   struct room * room;
   ...
};

 From what I can see, I'd use a record type for players and rooms, but 
I'm not sure how to replicate the pointer effects: keeping each player 
pointing to a single instance of a consistent world and maintaining the 
invariant that (given: p :: Player, r :: Room):

p `elem` (Room.players r) => (Player.room p == r)

This needs to stand up to concurrent modification of a shared world 
structure, but I think I'll set up the concurrency controls after I get 
my head around this.

-- Jack


More information about the Haskell-Cafe mailing list