>>>>> "Frank" == Frank A Christoph <[EMAIL PROTECTED]> writes:
> Peter Hancock wrote:
>> >>>>> "Marcin" == Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> writes:
>>
>> > What do you think would be the best representation of the buffer for
>> > such a crazy idea as a text editor in Haskell?
>>
>> I don't think its crazy. I thought that one could start with
>> something simple, like a "before" list and an "after list".
...
> ftp://ftp.cs.stir.ac.uk/pub/tr/cs/1994/TR116.ps.Z
> I think that they use the "before"/"after" approach too. (BTW, is this what
> is commonly called a "difference list"?) They reported rather poor
> performance, though.
To improve performance, I thought one can represent line structure. I
think that the original editor just represented the text by a
character sequence with a cursor, where \n was among the characters.
Here one could have a line sequence with a cursor, and a character
sequence with a cursor for the current line. So the state would be
something like
lbef : [ String ] -- complete lines before the cursor
cbef : String -- characters before cursor in current line
caft : String
laft : [ String ] -- complete lines after cursor.
I have seen a derivative of the editor written I think by Quentin
Miller which used a data structure a bit like this for the text.
One could use hierarchical lists if one was worried about good
performance with massive buffers.
> The Zipper technique is the generalization
> of this idea to arbitrary algebraic datatypes; it can be generalized to
> higher-order data too (continuations).
Is there some code around that illustrates the use of Zippers? They
sound very interesting.
Thanks
Peter