[Haskell-cafe] Re: Global Variables and IO initializers

2004-11-08 Thread Peter Simons
Adrian Hey writes: I don't see any value in problems that are specifically designed so that they can be solved only with a global entity. Even if it was true that I had specifically designed this problem, it's existance is of some interest I think. Perhaps my choice of words wasn't

[Haskell-cafe] Re: Arrows and Haskell

2004-11-06 Thread Peter Simons
Since I have been experimenting with Arrows quite a bit just recently, I feel compelled to add something to the discussion. I too think that Arrow are a beautifully simple and elegant concept. However, once you write production code, you notice quickly that there is a significant difference

[Haskell-cafe] Re: Processing of large files

2004-11-03 Thread Peter Simons
John Goerzen writes: Given that the block-oriented approach has constant space requirements, I am fairly confident it would save memory. Perhaps a bit, but not a significant amount. I see. [read/processing blocks] would likely just make the code a lot more complex. [...] Either

[Haskell-cafe] Re: Processing of large files

2004-11-02 Thread Peter Simons
John Goerzen writes: Read and process the file in blocks: I don't think that would really save much memory [...] Given that the block-oriented approach has constant space requirements, I am fairly confident it would save memory. and in fact, would likely just make the code a lot more

[Haskell-cafe] Re: Processing of large files

2004-11-01 Thread Peter Simons
Alexander N Kogan writes: I'm newbie and I don't understand how to process large files in haskell with constant memory requirements. Read and process the file in blocks: http://cryp.to/blockio/docs/tutorial.html Peter ___ Haskell-Cafe mailing

[Haskell-cafe] Re: Are handles garbage-collected?

2004-10-26 Thread Peter Simons
oleg writes: It seems you don't need to store the whole state in MVar: it's enough to store a `clean-up' action. Yes, that is good advice, I'll do that. Thank you, Oleg. Peter ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

[Haskell-cafe] Re: exitFailure under forkProcess

2004-10-26 Thread Peter Simons
John Goerzen writes: (progname): forkProcess: uncaught exception Quoting from the documentation: forkProcess :: IO () - IO ProcessID [...] On success, forkProcess returns the child's ProcessID to the parent process; in case of an error, an exception is thrown. What I assume is

[Haskell-cafe] Re: Are handles garbage-collected?

2004-10-24 Thread Peter Simons
Remi Turk writes: Assuming I could _not_ use 'bracket', 'withFile', 'finally' or any of the other usual scope-guarding techniques [...] Refactoring comes to the mind... ;) I wish that were possible! I use bracket-style resource allocation wherever I can, but in this case the Handle is

[Haskell-cafe] Re: Are handles garbage-collected?

2004-10-24 Thread Peter Simons
Keean Schupke writes: The _result_ of a rather complex computation return a function that returns the handle. The idea is good. :-) You'll find my other posting explains that a bit more: My main driver doesn't know about the handle; that's just one more entry in the state of the connection

[Haskell-cafe] Are handles garbage-collected?

2004-10-23 Thread Peter Simons
What happens when a System.IO.Handle falls out of scope without being explicitly hClosed? Is that a resource leak? Or will the RTS close the handle for me? Peter ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

[Haskell-cafe] Re: Stream processors

2004-10-21 Thread Peter Simons
Ben Rudiak-Gould writes: Must contexts be used in a single-threaded manner? If so, I would expect this interface: start :: IO ctx feed :: ctx - Buffer - IO () commit :: ctx - IO a 'feed' cannot have this signature because it needs to update the context. If not, I

[Haskell-cafe] Re: Stream processors

2004-10-21 Thread Peter Simons
K P SCHUPKE writes: This is the interface I came up with (and its fairly efficient): data IList a i e = ICons i i (a i e) (IList a i e) | INil Isn't that an interface for doing fast I/O rather than for writing stream processors? If I look at the consumer: wc :: List l Word8 = l Word8 -

[Haskell-cafe] Re: Stream processors

2004-10-21 Thread Peter Simons
K P SCHUPKE writes: Okay, maybe I misunderstood, I thought by stream processors you meant functions of the type: process :: [a] - [a] No, my stream processors currently have the API I described in my initial posting. What I was wondering is whether there is a more general API that I

[Haskell-cafe] Re: Stream processors

2004-10-21 Thread Peter Simons
Ben Rudiak-Gould writes: start :: IO ctx feed :: ctx - Buffer - IO () commit :: ctx - IO a 'feed' cannot have this signature because it needs to update the context. Sure it can -- it's just like writeIORef :: IORef a - a - IO (). I guess it's mood to argue that

[Haskell-cafe] Re: Stream processors

2004-10-21 Thread Peter Simons
K P SCHUPKE writes: My point was... using the IO library I posted which abstracts the buffer management, you can treat the IO as a simple list... Do you happen to have a ready-to-run word-counting example for me which is based on your library? I've tried to compile the code you posted, but

[Haskell-cafe] Re: Stream processors

2004-10-21 Thread Peter Simons
Jeremy Shaw writes: Here is a some code I scraped off the net a while ago, though I can't seem to find the origin anymore. I _think_ it is from part of Fudgets library: http://www.cs.chalmers.se/Cs/Research/Functional/Fudgets/ Thanks for posting it, though, this implementation is rather

[Haskell-cafe] Re: Stream processors

2004-10-21 Thread Peter Simons
Ben Rudiak-Gould writes: bar :: StreamProc ctx a - IO (a,a) bar sp = do ctx - start sp (ptr1,n1) - ... (ptr2,n2) - ... ctx1 - feed sp ctx (ptr1,n1) ctx2 - feed sp ctx (ptr2,n2) val1 - commit sp ctx1 val2 - commit sp ctx2 return (val1,val2)

[Haskell-cafe] Re: Subsequence near solved hopefully

2004-10-17 Thread Peter Simons
Sam Mason writes: Just to muddy the water a bit. . . What happens if the second string is infinite? This version should do it: isSubSeq :: (Eq a) = [a] - [a] - Bool isSubSeq [] _= True isSubSeq _ []= False isSubSeq (x:xs) (y:ys) | x == y= isSubSeq xs ys |

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-08 Thread Peter Simons
Ketil Malde writes: Couldn't readFile et al. provide the standard interface, but use hGetBuf tricks (e.g. from your 'wc' entry) behind the curtains? No amount of hGetBuf'ing will speed the program up if the problem is the algorithm. I/O comes _sequentially_, and every program that doesn't

[Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Peter Simons
Keith Wansbrough writes: Count me as a vote for the better-but-slightly-slower wc. How about the attached program? On my machine it faster than Tomasz's version, and I think it's still a fairly clean source code. Using some random large file for input, I got these results with time(1): real

[Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Peter Simons
Josef Svenningsson writes: What *is* true is that it is difficult to write good performance I/O in any of the *implementations* that we have. GHC has everything you need to do fast I/O in Haskell. If you use hGetBufNonBlocking with 'Ptr a', you have essentially the performance of read(2).

[Haskell-cafe] Tutorial about low-level I/O in Haskell

2004-10-05 Thread Peter Simons
Hi, while polishing a small library of mine, I ended up writing a tutorial about the use of hGetBufNonBlocking and the related Foreign.* functions you need to do fast, block-oriented I/O in Haskell. There is something to be said for literate programming. Using recent topics for inspiration, the

[Haskell-cafe] State monad strictness (was: ... abysmal Language Shootout results)

2004-09-30 Thread Peter Simons
How can anyone stay away from such a deliciously pointless waste of time as implementing a wc(1) derivate? :-) Here is my attempt: import IO type Count = Int data CountingState = ST !Bool !Count !Count !Count deriving (Show) initCST = ST True 0 0 0

[Haskell-cafe] Re: Silly I/O question

2004-09-28 Thread Peter Simons
John Goerzen writes: That failed, though, because getContents closes the file after it's been completely read (ugh -- why?). getContents reads from standard input: you can't seek on that stream. Just think of cat file | cat. The second invocation reads from a pipe, not from a file on disk.

[Haskell-cafe] Re: file upload with Network.CGI

2004-08-27 Thread Peter Simons
Glynn Clements writes: About the only functions in Network.CGI which might be useful for processing file uploads are getQueryString and getCgiVars, neither of which are exported. Fortunately, another reader of this list has written the necessary parsers already and sent me a copy of the

[Haskell-cafe] file upload with Network.CGI

2004-08-26 Thread Peter Simons
Has anyone managed to process the results of a file upload formular, such as form action=input_file.htm enctype=multipart/form-data pChoose a file: input name=foobar type=file size=50 maxlength=10 accept=text/* /p /form ..., with Network.CGI successfully? I

I/O multiplexing (repost)

2003-10-27 Thread Peter Simons
[ I'm posting this article here again, because the general ] [ mailing list seems to be closed to non-members, and I'm ] [ reading/posting through gmane.org. Pardon me, if you see ] [ this on both lists, please. -peter ] Hi, I have a question concerning manual I/O

Re: replacing guile with haskell?

2003-10-22 Thread Peter Simons
Graham Klyne writes: I'm thinking in particular that a function that turned a regular expression into a Parsec parser function could be useful, as in: regexp.compile :: String - GenParser Char st [String] Just curious: Why would you want something like that? I thought that the good

Re: Generating setMember functions for record structures

2003-09-25 Thread Peter Simons
Peter Gammie writes: Haskell Report, Sec 3.15.3 Great, that's exactly what I need. Thanks a lot to all who replied! Peter ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Fast I/O with sockets

2003-09-17 Thread Peter Simons
Simon Marlow writes: hGetLine should work fine, indeed that's what I used in the Haskell Web Server. Well, another -- and more important -- problem with hGetLine is that it will read an arbitrarily long line. An attacker might use this to implement an denial-of-service attack simply by

Querying DNS from Haskell

2003-09-16 Thread Peter Simons
Hi, is anyone aware of a library for Haskell, which allows to query domain name servers for MX, A, and PTR records in a non-blocking way? My first guess was to create an Interface to ADNS [1], but I figured, maybe someone else has already solved this problem? Peter [1]

Re: accessing Haskell-Cafe from oe

2003-07-07 Thread Peter Simons
Jeff Aimt writes: [haskell-cafe via news server] You can access the mailing list via NNTP under the name gmane.comp.lang.haskell.cafe on news.gmane.org. See http://www.gmane.org/ for further details. Peter ___ Haskell-Cafe mailing list [EMAIL

Using SGML/XML in literate code

2003-01-06 Thread Peter Simons
I understand that I can mark-up code segments in a literate source module using the syntax: \begin{code} ... \end{code} But is it somehow possible to re-define this to be haskellcode ... /haskellcode instead? I am asking because the latter style would enable me to write

Parsing date and time specifications

2002-12-19 Thread Peter Simons
Hi, I have written a parser that turns an RFC2822 date and time specification into a datatype usable in Haskell. While the parser is working just fine so far, I have a problem with the CalendarTime datatype. It appears that in order to construct one of those, I need _all_ the information it

Re: Calling Haskell from Python / C++

2002-11-14 Thread Peter Simons
Simon Peyton-Jones writes: I hope it's all described adequately in the GHC user manual http://haskell.org/ghc I'll take a look at it, thanks! Unfortunately, before I can worry about this I have to get GHC built at all. It appears that the available binary versions don't work an a pure

Re: Calling Haskell from Python / C++

2002-11-13 Thread Peter Simons
Simon Peyton-Jones writes: If Python uses C's calling convention, it might be easy; just use 'foreign import' and 'foreign export' (see the FFI spec at haskell.org). I remember reading that the main program, that wants to call Haskell code, would have to be compiled with a special Haskell

GUI Library for Visualizing Data

2002-11-04 Thread Peter Simons
Hi, the Haskell language is fairly new to me, so please pardon me if this is a frequently asked question, but I wasn't able to find an answer myself. I'm looking for a library that allows me to visualize data under X11 screen, for instance as a pie chart or as a bar chart. I seem to recall that

<    1   2