Space leak? Was: [Haskell] Queues / Lists with unbound tails

2004-05-09 Thread andrew cooke
Claus Reinke said: > initQ n = foldr (.) id $ take n $ repeat (Nothing:) > pushQ front q = tail . q . (front:) Why doesn't repeated pushing give a space leak? As far as I can see, tail never gets a "complete" list on which it can act, so repeated pushing will construct a function with more

Re: [Haskell] Queues / Lists with unbound tails

2004-05-08 Thread andrew cooke
Claus Reinke said: [...] > something like this? > > initQ n = foldr (.) id $ take n $ repeat (Nothing:) > pushQ front q = tail . q . (front:) > peekQ q = (head $ q [], q) Yes, thanks. At least, it looks easy to get what I want from that. Sigh. It seems so obvious now. When will th

Re: [Haskell] Queues / Lists with unbound tails

2004-05-08 Thread andrew cooke
Claus Reinke said: > You can't really pop from a fixed-length queue. Apart from that, something like this? Just to clarify, I want something with a *single* operation that takes one value, adding it to the front of the queue, and returns a tuple containing the value that was at the end of the qu

[Haskell] Queues / Lists with unbound tails

2004-05-08 Thread andrew cooke
Hi, I'm trying to write a simple fifo queue of fixed length (containing type Maybe a - it would be initialised to Nothings) where pushing an item pops the "last" item "off the end". data Queue a = QUEUE (Maybe a -> (Queue a, Maybe a)) queue :: Maybe a -> Queue a queue n1 = QUEUE (\n2 -> (queue

Re: [Haskell] Ann: Halipeto 1.1 (web page templates)

2004-02-13 Thread andrew cooke
Malcolm W - thanks for your comments. I did reply (nothing important), but your university has my address blacklisted (dynamic ip). Sorry for the on-list noise. Andrew andrew cooke said: [...] > Halipeto generates web pages from templates (much like JSP, Zope TAL etc). > It's

[Haskell] Ann: Halipeto 1.1 (web page templates)

2004-02-13 Thread andrew cooke
Hi, Halipeto generates web pages from templates (much like JSP, Zope TAL etc). It's written in Haskell (with a ghc extension) and is available from http://www.acooke.org/jara/halipeto An example site generated using Halipeto, containing some Pancito images, is at http://www.acooke.org/pancito -

[Haskell] Ann: Pancito 2.2

2004-02-10 Thread andrew cooke
Hi, There's a new version (2.2) of Pancito (a functional images toolkit) available at http://www.acooke.org/jara/pancito - it extends 2.1 with useful output options (a progress meter and the possibility to preview a small area of an image) and better structured code (points are now a typeclass, a

Re: [Haskell] ANNOUNCE: HsUnix 1.0.1 - Haskell for Unix ShellScripting

2004-02-09 Thread andrew cooke
wouldn't it be nicer to have - mainwrapper and call combined - helper fucntions defined for execp "cat" etc i haven't downloaded your package, but the syntax as it is looks very verbose. i know it's a small point, but shells have to support a compact syntax (or is the idea only to support "shell

Re: [Haskell] Weaving the Web with Haskell

2004-02-03 Thread andrew cooke
HaXml doesn't explicitly handle namespaces, but they appear in the attribute name. I've used HaXml on Windows (actually, a subset of the modules) to implement a simple template engine that relies on an XML namespace to call functions in Haskell. So, for example is converted into output from so

Re: Type classes confusion

2004-01-10 Thread andrew cooke
Ah. I just need to drop the context from the data type declaration. Sorry, Andrew andrew cooke said: > > Hi, > > I'm trying to use type classes and suspect I've got confused somewhere > down the line, because I've got to an error message that I don't > und

Type classes confusion

2004-01-10 Thread andrew cooke
Hi, I'm trying to use type classes and suspect I've got confused somewhere down the line, because I've got to an error message that I don't understand and can't remove. I have a class that works like a hash table, mapping from String to some type. I have two instances, one that is case insensit

Re: How to make reading an array from disk more efficient

2003-12-24 Thread andrew cooke
Thanks. I should have added that I will only use the array for reading once it's created. I don't mind whether creating is lazy or eager (it's currently eager because I was fighting a space leak, but I think that was down to some other error). I don't fully understand how either of the suggesti

How to make reading an array from disk more efficient

2003-12-24 Thread andrew cooke
Hi, I have some code (http://www.acooke.org/andrew/ReadTest.hs) that reads data from a file (an image in ppm format; example data (256*256 pixels) at http://www.acooke.org/andrew/test.ppm) and stores it in an array of Word8 values. The aim is to read a file that contains 5000 * 5000 * 3 Word8 va

Re: Parsing HTML

2003-12-10 Thread andrew cooke
hope that's OK, because maybe someone will find this info via Google one day and find it useful. Cheers, Andrew Malcolm Wallace said: > "andrew cooke" <[EMAIL PROTECTED]> writes: > >> - HaXml looks like it might do what I want, but >> (1) seems tricky to inst

Re: Parsing HTML

2003-12-10 Thread andrew cooke
It appears that the Haskell XML Toolbox may be what I want - http://www.fh-wedel.de/~si/HXmlToolbox/ - but any other suggestions would be appreciated. Apologoies for relying on Haskell.org rather than Googling (I'll mail the web page maintainers). Cheers, Andrew andrew cooke said: > &g

Parsing HTML

2003-12-10 Thread andrew cooke
What are the options for parsing/lexing (X)HTML? As far as I can see... - the HTML library in GHC (or from Andy Gill) is for creating documents, not parsing them - HaXml looks like it might do what I want, but (1) seems tricky to install (needs "make", which isn't that cool for Windows); (2) h

Re: Incomplete output when hPutStr is lifted

2003-11-29 Thread andrew cooke
Tomasz Zielonka said: > On Thu, Nov 27, 2003 at 04:09:00PM -0300, andrew cooke wrote: [...] >> If I compile and run the code below, the file "foo" contains 10 lines >> of output (as I would expect), but the file "bar" contains just 9 - >> the final line

Incomplete output when hPutStr is lifted

2003-11-27 Thread andrew cooke
Hi, If I compile and run the code below, the file "foo" contains 10 lines of output (as I would expect), but the file "bar" contains just 9 - the final line is missing. If I add a "join", as in the comment, then all 10 lines appear. I don't understand why, completely - my best guess is that it'

Inspecting reduced/optimized code

2003-11-10 Thread andrew cooke
Is it possible/easy in any of the compilers/interpreters to see what the results of rewriting/optimisations are? (I'm sure it is *possible*, I'm really asking if any produce simple output in a well documented format that I'm likely to understand). The reason I ask is because I'm curious whether

Re: Expiring cached data?

2003-11-05 Thread andrew cooke
[EMAIL PROTECTED] said: [...] > If you can wait a day or two, I have some code which needs to be cleaned > up which does pretty much this. Thanks to everyone who's replied (including some replies I see in the inbox that I have not read yet). Yes, I can certainly wait (and would be interested to

Expiring cached data?

2003-11-02 Thread andrew cooke
I have a Haskell program that caches data in a tree. Unfortunately, the tree grows to exceed the available memory over time. In a different language, where I might be handling the caching myself, rather than relying on laziness within the language, I might work round this by keeping track of wh