Re: [Haskell-cafe] Mutable data design question

2004-12-06 Thread Keith Wansbrough
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 ... Better to store it as a pair of the most recent state, and a list of *reversed* changes.

Re: [Haskell-cafe] Mutable data design question

2004-12-05 Thread ajb
G'day all. Quoting Marcin 'Qrczak' Kowalczyk [EMAIL PROTECTED]: 2. Use a persistent data structure with logarithmic cost of most operations: a balanced tree of text fragments, called a rope (Hans Boehm has made one for C). Undo can be made by simply keeping old versions. Hard

[Haskell-cafe] Mutable data design question

2004-12-03 Thread GoldPython
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 [EMAIL PROTECTED]

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Keean Schupke
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

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Robert Dockins
I imagine you would want to use a truly mutable data structure in the IO monad -- something like an STUArray of Chars. GoldPython wrote: 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

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Marcin 'Qrczak' Kowalczyk
GoldPython [EMAIL PROTECTED] writes: 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? This is specific to text editors: 1. Use a traditional mutable data structure,

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Ben Rudiak-Gould
GoldPython wrote: 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? I wouldn't say that textual data is by its nature mutable. That's just the imperative way of looking at

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Marcin 'Qrczak' Kowalczyk
Keean Schupke [EMAIL PROTECTED] writes: What happens with this method when the display needs refreshing, does the current state have to be recomputed every time ... No. The new state is constructed from bits of old state and the changed data. Applying a change on average requires logarithmic

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Jason Bailey
I'm going to take by your replies that you've never worked for a major corporation. :) Thats okay. Cause unless you've really been in the grind of their operations it can seem irrational from the outside I'm giving examples of the difficulties that would be faced in attempting to get managers

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread GoldPython
I have the same experience. I wish it wasn't so, but it is. I've been playing with Haskell since before Haskell 98, and until I joined this email list a couple weeks ago, I had never met another human being that knew what functional programming was much less had done any. I've been working around

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Scott Turner
On 2004 December 03 Friday 15:16, GoldPython wrote: until I joined this email list a couple weeks ago, I had never met another human being that knew what functional programming was My experience has been different in Massachusetts. At my first job after my Comp Sci degree, developing

Re: [Haskell-cafe] Mutable data design question

2004-12-03 Thread Jérémy Bobbio
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 3 déc. 04, at 17:28, GoldPython wrote: 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? Maybe you should take a look at Yi