[Haskell-cafe] trees and pointers

Serguey Zefirov sergueyz at gmail.com
Thu Jul 15 06:14:46 EDT 2010

2010/7/15 Sergey Mironov <ierton at gmail.com>:
> 2010/7/15 Serguey Zefirov <sergueyz at gmail.com>:
>> 2010/7/14 Sergey Mironov <ierton at gmail.com>:
>>> Hi cafe! I have a question of C-to-Haskell type:)
>>> Imagine web application wich allows users to browse some shared
>>> filesystem located at the server.
>>> Application stores every users's position within that filesystem
>>> (current directory or file).
>>> In C this can be implemented with the help of following data types:
>>> Any ideas?
>> Use IORef. ;)
>> PS
>> MVar is better, actually.
> Somehow I forgot about them:) Code will turn into something like
> It really should work! (we don't take multithreading issues into
> account for now)
> Slightly annoying thing is that 1-to-1 mapping from C to Haskell also
> forces programmer to perform C-like low-level pointer linking.

This is just straightforward solution and it contains some number of
traps. What if someone disconnected a part of "file system" while some
user browses it? That user will be trapped inside that island (or get
a core dump), How do users get notifications about changes in their
parts of structures?

You can do better but, of course, it will be harder.

The browsing itself is a simple variant of collaborative editing:
http://en.wikipedia.org/wiki/Collaborative_editing Your variant is
simpler that editing because only one member produce changes in
structure. So you could send tree diffs in Zipper format to all your
users or accumulate diffs and give them to users when they ask for it.

Adding tree diff over user position described as Zipper won't put user
into an isolated island.

And if you later decide that there are two parties who can change the
world, you are almost fully prepared for it.

More information about the Haskell-Cafe mailing list