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". Sometime
> ago, there was an article by Bernard Sufrin, which specied a simple
> editor various derivatives of which were in use in Oxford over a
> decade ago. If I recall the article accurately, it was so
> clearly written that
> you could more or less just transcribe it into a functional program.
> Perhaps one can find it from
> http://www.comlab.ox.ac.uk/oucl/people/bernard.sufrin.html
Also check this one out:
Simon P. Booth, and Simon B. Jones "A screen editor written in the Miranda
functional programming language" ,Technical report TR-116, Department of
Computing Science and Mathematics, University of Stirling, February 1994.
You can find it at:
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.
Incidentally, the "before"/"after" list approach is actually a special case
of the "Zipper" (I prefer to call them context-enriched types), which
someone mentioned in an earlier post: the "before" part is the context for
the "after" part, which is the focus, and, sure enough, the context has been
turned inside-out like a glove. It just happens that for (vanilla) lists the
context is isomorphic to a list. The Zipper technique is the generalization
of this idea to arbitrary algebraic datatypes; it can be generalized to
higher-order data too (continuations).
--FC