[Haskell-cafe] Transactional in-memory model
vlca01 at tiscali.cz
Sat Aug 20 14:37:50 EDT 2005
I am new to Haskell, coming from an object-oriented realm.
As an exercise I am trying to develop an API for accessing/changing services
configuration in a SysV-like init environment.
Being object-oriented I have defined a model of runlevels/services and a
parser that creates instances of these structures from the underlying files.
That way my program is able to interrogate the current state of the services
Now I would like to ask how to go about designing the part that will make
changes to the config in respect to the following requirement.
I want the API to allow making changes only to the model and then applying
them back to the filesystem at once. This is to support UI where the user
will make various changes and then hit "Apply" or "Cancel".
I am imagining this as a sort of simple transactional behaviour of the
At the moment I am thinking of passing the whole model around through the
various API functions, that will make the changes, but there are many
questions to be answered.
I need to keep the original model state and a stack of the changes made so
that at commit-time I can figure out what has been changed. Also some changes
might affect each other (add service followed by remove service, etc.).
Anyway the main question is how should such a scenario be approached.
Can anyone throw in some ideas to get me started?
It might well be that this whole idea of a model with changing state is wrong
in respect to FP. If so, what would the right way be?
More information about the Haskell-Cafe