Functional implementation (e.g. in Haskell) of GoF's Lexi Editor application

I am trying to understand how one can use functional programming to implement applications which are usually implemented using an OO/imperative-approach.

One important category of applications is editors (Word, Evernote, PowerPoint, Photoshop etc).

Let's consider GoF's Lexi Editor application as a representative and well-known example whose object-oriented/imperative solution has been described in great detail in the GoF book.

How would one write the equivalent of GoF's Lexi application in Haskell ?

Would that be possible at all ? How would the time/memory complexity compare in the OO/imperative vs. FP/immutable approaches ?

What would the general architecture of that application (Lexi) be when implemented in Haskell ?

How would it be better or worse than the non-functional/object-oriented solution described in the GoF book ?

Thanks for reading.

EDIT/ANSWER:

The book ' The Haskell School of Expression ' seems to answer this question. It shows (among other things) how to develop a graphical editor in Haskell.

EDIT 2 : This presentation seems to also answer this question (not directly though).


I'll address your one question which has an objective answer:

Would [writing the equivalent of GoF's Lexi application in Haskell] be possible at all ? How would the time/memory complexity compare in the OO/imperative vs. FP/immutable approaches ?

Yes, it would be possible. There are no inherent time/memory complexity constraints in Haskell compared to "OO/imperitive approaches", if you admit something as simple as the ST monad. Without the ST monad, it's an open problem whether purely functional languages with lazy evaluation can achieve the same time performance as mutable languages. They are certainly within a time performance factor of log(M) where M is the amount of memory used in the mutable system; this can be easily seen by building a mutable memory system out of a tree.

链接地址: http://www.djcxy.com/p/80874.html

上一篇: IO monad是什么意思(如果有的话)?

下一篇: GoF的Lexi Editor应用程序的功能实现(例如,在Haskell中)