Soliciting comments on Edison
Andrew J Bromage
ajb@spamcop.net
Thu, 29 May 2003 15:39:11 +1000
G'day all.
As some of you know, I'm hacking up Edison. I'd like some suggestions
on namespace issues. Note that at the moment, "Edison" has its own
top-level name in the libraries document, and I'm happy for things
to stay that way for now.
First, an overview. Edison is a library of data structures, based
around three main concepts:
- A Sequence is any container where order is maintained
(e.g. stacks, queues, deques, lists etc).
- A Collection is a container where order is not maintained,
or rather, is maintained by constraints on the ADT (e.g.
sets, bags, priority queues etc).
- An Association is a container which maps some key type
to some data type (e.g. search trees, hash tables etc).
The main feature of Edison which distinguishes it from other data
structure libraries is that you do not choose data structures by the
set of operations which you can perform on them because, for example,
all Sequences support the same set of operations. Instead, you pick
your data structure by implementation, and live with the fact that
some operations are going to be slow on some implementations (e.g. snoc
on simple lists is O(n)).
Clearly, this is suboptimal. From a programmer's perspective, I
shouldn't have to remember the difference between a BinaryRandList
and a JoinList.
Hence, I have started to implement what I call "facade" types, which
wrap underlying implementations to give them names which better
reflect what they are used for. Rather than use an Edison.ListSeq,
you use an Edison.Stack and use meaningful operations like push and
pop rather than cons and tail.
I also want to support concurrently accessible data structures,
embedded in the IO monad, which will probably be implemented as
wrapper functions on top of channels or ports.
So now there are three kinds of ways to look at a data structure:
- As a concrete implementation
- As a facade, exposing those operations that it is optimised for
- As a concurrently accessible abstraction
The simplest namespace would be something like this:
Edison
-- Top-level modules may include:
Prelude
Sequence
Collection
Association
Facade -- Need a better name
Stack
Queue
Deque
FiniteMap
FiniteTrie
Concurrent
Stack
Queue
Deque
FiniteMap
FiniteTrie
Impl
Sequence
BraunSeq
MyersStack
Collection
SplayHeap
BalancedSet
BalancedBag
Assoc
PatriciaLoMap
Another option is to dump everything in "Facade" into the top level,
but presumably that would require everything in Concurrent to be in
the top level too which seems to pollute the top-level namespace a
bit too much.
Thoughts?
Cheers,
Andrew Bromage