[Haskell-cafe] Mutable data design question
k.schupke at imperial.ac.uk
Fri Dec 3 11:37:41 EST 2004
Well, if you consider large word-processors like word keep a complete
undo history, I
would keep a document as a list of changes:
data Document = Insert Location String | Delete Location Location ...
so a document may look like:
[Insert 0 "Hello World", Delete 6 10, Insert "\n World"]
But you will still need mutable state for the actual edit buffer.
You also need to decide if you want to be able to edit files larger than
memory... If so
a mutable state buffer using the ST monad is probably the way to go
>In the case of writing something like a text editor where the data
>involved is by its very nature mutable, what sort of design paradigm
>would you use in a functional language?
>Haskell-Cafe mailing list
>Haskell-Cafe at haskell.org
More information about the Haskell-Cafe