AW: slide: useful function?

Andrew J Bromage ajb@spamcop.net
Tue, 3 Dec 2002 10:40:00 +1100


G'day all.

On Mon, Dec 02, 2002 at 01:05:27PM -0500, David Bergman wrote:

> It seems like all the patterns, at least the ones in the GoF's
> enumeration, can be expressed as higher-order functions and classes if
> we only would have a way to traverse a record structure dynamically. If
> someone can think of a "design pattern" (such as one from the GoF book)
> which is not expressible directly in Haskell, up to data type structure
> (i.e., assuming the structure to be list or a fixed tree structure...),
> please let us know.

Here's one:

	Gérard P. Huet, "The Zipper." JFP 7(5): 549-554 (1997)

This pattern, used for traversing data structures in all directions
including "up", is directly expressible in languages with pointers
but is not directly expressible in Haskell 98 (unless you use indirect
data structures, but they remove a lot of the benefit of using Haskell 
ata structures, like pattern matching) so the zipper pattern (or
something like it) is required.

No, I didn't pick an example from the GoF book.  The GoF book deals
exclusively with imperative OO languages, so we should not expect
their particular set of patterns to be as useful to us.

Cheers,
Andrew Bromage