Re: Representing cyclic data structures efficiently in Haskell

2003-07-12 Thread andrew cooke
Sarah Thompson <[EMAIL PROTECTED]> writes: [...] > work that well for circuits because, for anything other than trivially > simple components, the connections between nodes need to be labelled. it's been a while since i used it, but i thought erwig's graph library had labels on edges. it's a real

Re: Representing cyclic data structures efficiently in Haskell

2003-07-08 Thread C.Reinke
> What is the best way to represent cyclic data structures in Haskell? There used to be some work on direct cyclic representations at UCL: Dynamic Cyclic Data Structures in Lazy Functional Languages Chris Clack, Stuart Clayman, David Parrott Department of Computer Science, University Colleg

Re: Representing cyclic data structures efficiently in Haskell

2003-07-08 Thread John O'Donnell
Hi Sarah, On Mon, 2003-07-07 at 16:04, Sarah Thompson wrote: > What is the best way to represent cyclic data structures in Haskell? > > Lists are trivial. Trees are trivial. But what if the thing you're > trying to represent is shaped like an electronic circuit, ... > ... > How do people typical

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Andrew J Bromage
G'day all. On Mon, Jul 07, 2003 at 04:37:46PM +0100, Sarah Thompson wrote: > I'd considered something like embedding the type in the IO monad, with > links between components implemented as IORefs, but I'd really prefer > something cleaner (pure functional). If the code ends up horribly > comp

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Andrew J Bromage
G'day all. On Mon, Jul 07, 2003 at 04:04:17PM +0100, Sarah Thompson wrote: > > I would also need to implement efficient indexes into the data structure > > -- flat searching will be too slow for non-trivial amounts of data. In > > C++, I'd implement one or more external (probably STL-based) ind

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Andrew J Bromage
G'day all. As you note, some kind of indirection is what you want here. On Mon, Jul 07, 2003 at 04:04:17PM +0100, Sarah Thompson wrote: > I would also need to implement efficient indexes into the data structure > -- flat searching will be too slow for non-trivial amounts of data. In > C++, I'd

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Christopher Milton
--- Sarah Thompson <[EMAIL PROTECTED]> wrote: > What is the best way to represent cyclic data structures in Haskell? You _might_ find some useful ideas in Franklyn Turbak and J. B. Wells. Cycle Therapy: A Prescription for Fold and Unfold on Regular Trees. Third International Conference on Princ

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Graham Klyne
Lazy evaluation means that you can embed nodes directly in a cyclic structure, even though that would appear to create an indefinite regression. In order to detect cycles, one might add a node identifier. Here's a simple example: [[ -- spike-cyclicstructure.hs data Node = Node { nodeid :: Str

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Sarah Thompson
From reading your message, it seems you want a graph library of sorts. The important bit is 'of sorts', unfortunately! Most graph libraries I've seen to date (although I must admit that they have been written in C and C++, including one I perpetrated personally) don't really work that well for

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Lex Stein
Why not just use a GUID to represent each node. Then a C pointer just becomes a GUID in a tuple alongside the node. The C pointer approach is just a method to have the memory system dole out GUIDs. And it can be generalised. Then all the tuples could be inserted in a hash table on the GUID compone

Re: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Antony Courtney
Hi Sarah, Representing cyclic structures is indeed somewhat tricky in a pure functional language. The obvious representation (representing the link structure implicitly in an algebraic data type) doesn't work, because you can't obvserve cycles. I recommend checking out two pieces of work in t

RE: Representing cyclic data structures efficiently in Haskell

2003-07-07 Thread Hal Daume
>From reading your message, it seems you want a graph library of sorts. I've used FGL extensively and found it to be very nice. It even provides both a purely functional interface as well as an imperative-esque interface. It also comes with a bunch of standard algorithms built in, though I don't