Re: [Haskell-cafe] Re: Top Level etc.

2005-01-20 Thread Ben Rudiak-Gould
Jim Apple wrote: Does anyone have examples of these? This one scares the foo out of me: * It's not even safe in general to add a signature giving the same type that the compiler would infer anyway Here's an example: len :: [a] - Int len xs = let ?accum = 0 in len' xs len'

Re: [Haskell-cafe] Re: Top Level etc.

2005-01-20 Thread Keean Schupke
Ben Rudiak-Gould wrote: len :: [a] - Int len xs = let ?accum = 0 in len' xs len' :: forall a. (?accum :: Int) = [a] - Int len' [] = ?accum len' (x:xs) = let ?accum = ?accum + (1::Int) in len' xs *Main :t len' len' :: forall a. (?accum :: Int) = [a] - Int

RE: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Simon Marlow
On 19 January 2005 20:31, Glynn Clements wrote: Keean Schupke wrote: Okay, my ignorance of Posix is showing again. Is it currently the case, then, that every GHC thread will stop running while a disk read is in progress in any thread? Is this true on all platforms? It's true on Unix-like

RE: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Simon Marlow
On 19 January 2005 20:33, Glynn Clements wrote: Simon Marlow wrote: We do use a thread pool. But you still need as many OS threads as there are blocked read() calls, unless you have a single thread doing select() as I described. How does the select() help? AFAIK, select() on a regular

Re: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Keean Schupke
Why is disk a special case? I have never heard that all processes under linux wait for a disk read... The kernel most certainly does not busy wait for disks to respond, so the only alternative is that the process that needs to wait (and only that process) is put to sleep. In which case a second

RE: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Simon Marlow
On 19 January 2005 16:58, Keean Schupke wrote: Simon Marlow wrote: This is what GHC does, if I understand you correctly. The thread running select() does so in its own OS thread, while another OS thread runs the Haskell code. As long as you use -threaded, that is. Oh, and before GHC 6.4

Re: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Keean Schupke
Simon Marlow wrote: We're getting a bit confused here. Keean: the original question was about whether a disk read will stop all other *Haskell* threads. Not OS threads. The two are quite different beasts in GHC. Cheers, Simon But if GHC is running with the -threaded flag, then other

RE: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Simon Marlow
On 20 January 2005 09:56, Keean Schupke wrote: Why is disk a special case? I have never heard that all processes under linux wait for a disk read... You were talking about Haskell threads, not processes! These are quite different things. The kernel most certainly does not busy wait for

Re: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Keean Schupke
Simon Marlow wrote: On 20 January 2005 09:56, Keean Schupke wrote: Why is disk a special case? I have never heard that all processes under linux wait for a disk read... You were talking about Haskell threads, not processes! These are quite different things. But with -threaded GHC is

RE: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Simon Marlow
On 20 January 2005 10:01, Keean Schupke wrote: Simon Marlow wrote: We're getting a bit confused here. Keean: the original question was about whether a disk read will stop all other *Haskell* threads. Not OS threads. The two are quite different beasts in GHC. Cheers, Simon

Re: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Keean Schupke
Simon Marlow wrote: Yes, except that you forgot that not all foreign calls can run concurrently with Haskell code. Only the safe ones can. Okay, now I understand what is going on. Why is there extra overhead for a 'safe' call? Keean. // ___

[Haskell-cafe] Re: I/O interface

2005-01-20 Thread Andre Pang
On 20/01/2005, at 3:42 AM, Keean Schupke wrote: Have you read the OOHaskell paper? http://homepages.cwi.nl/~ralf/OOHaskell/ This shows how to encode many OO idioms in Haskell, without any extensions (beyond those that GHC already supports)... Here's some sample code (from the Shapes.hs

Re: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Keean Schupke
But does it matter... If the select says the read will block you schedule another haskell thread, if select says the read will not block, you do the read. I don't see the problem... (Okay, I can see that if select lies, and the read takes a long time you might miss the next scheduling timeslot -

[Haskell-cafe] Re: I/O interface

2005-01-20 Thread Keean Schupke
Andre Pang wrote: Just because you can encode the OO idioms in Haskell doesn't mean it's particularly straightforward to use them. As your example shows, getting the syntax right for these OOish constructs isn't easy (not to mention verbose), and even so, the type errors you face when you get

RE: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Simon Marlow
On 20 January 2005 11:30, Keean Schupke wrote: Simon Marlow wrote: Yes, except that you forgot that not all foreign calls can run concurrently with Haskell code. Only the safe ones can. Okay, now I understand what is going on. Why is there extra overhead for a 'safe' call? A safe

[Haskell-cafe] Re: I/O interface

2005-01-20 Thread Andre Pang
On 20/01/2005, at 11:06 PM, Keean Schupke wrote: I find it no harder than writing with monads for example... certainly there are some tricky things going on in both... but that doesn't stop people using monads for IO, state etc. Syntactic sugar over the top for instance and implementation

Re: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Keith Wansbrough
read. I don't see the problem... (Okay, I can see that if select lies, and the read takes a long time you might miss the next scheduling timeslot - but as far as I am aware select doesn't lie, and read will return immediately if select says there is data ready)... select() _does_ lie for

[Haskell-cafe] Problems with compiling wxFruit

2005-01-20 Thread Dmitri Pissarenko
Hello! I'm trying to compile wxFruit sample program paddleball (http://zoo.cs.yale.edu/classes/cs490/03-04b/bartholomew.robinson/). When I try to compile file paddle.hs (see below where it is availeble) using the call call ghc -fglasgow-exts -farrows -package wx

[Haskell-cafe] Re: I/O interface

2005-01-20 Thread Keean Schupke
Andre Pang wrote: The syntactic sugar is the killer. (Using monads is really no fun if you don't have do notation, for example. Doable: yes. Pretty: definitely not!) Even if you use Template Haskell to try to implement the syntactic sugar, you're very limited by the splice $(...) notation

Re: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Keean Schupke
Keith Wansbrough wrote: read. I don't see the problem... (Okay, I can see that if select lies, and the read takes a long time you might miss the next scheduling timeslot - but as far as I am aware select doesn't lie, and read will return immediately if select says there is data ready)...

Re: [Haskell-cafe] Problems with compiling wxFruit

2005-01-20 Thread shelarcy
You hace to add option --make, if you complie haskell program file with (Bsome files. (BAnd, you have to change WX.size to Wx.sz . (BBecause wxHaskell-0.8 changed some functions. (B (BOn Thu, 20 Jan 2005 15:50:29 +0100, Dmitri Pissarenko (B[EMAIL PROTECTED] wrote: (B I'm trying to compile

Re: [Haskell-cafe] Problems with compiling wxFruit

2005-01-20 Thread Dmitri Pissarenko
Thanks all for the help! Now it works. -- Dmitri Pissarenko Software Engineer http://dapissarenko.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Re: Answers to Exercises in Craft of FP

2005-01-20 Thread Gour
David Owen ([EMAIL PROTECTED]) wrote: Unfortuantely I don't know of anywhere that the exercise answers can be found, even after some google searching. I would definitely find them useful though as there are a couple I haven't been able to work out. Me too. And I hope we're not the only one

Re: [Haskell-cafe] RE: Answers to Exercises in Craft of FP

2005-01-20 Thread Gour
Ketil Malde ([EMAIL PROTECTED]) wrote: Another option is posting the excercise to this list (or perhaps in comp.lang.functional), along with your current effort at solving it. I consider it would be useful to have the the whole collection somewhere, maybe on wiki since Thompson's book (beside

[Haskell-cafe] Reading images

2005-01-20 Thread Dmitri Pissarenko
Hello! I need to write a function in Haskell, which 1) reads a greyscale image (for instance, in JPEG, PNG or the like) and 2) transforms it into a n X m matrix A, where Aij contains an integer value (in the range 0 to 255). That integer value is zero for a completely black pixel, 255 for a

[Haskell-cafe] File path programme

2005-01-20 Thread Mark Carroll
I tried writing a little command-line utility to find the relative path of one thing from another thing (with Unix-like systems in mind). For example, $ ./pathfromof /etc/init.d/ /etc/X11/XF86Config-4 ../X11/XF86Config-4 $ ./pathfromof /tmp/baz/ /tmp/foo/ . $ ls -l /tmp/baz lrwxr-xr-x 1 markc

Re: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Glynn Clements
Keean Schupke wrote: Why is disk a special case? With slow streams, where there may be an indefinite delay before the data is available, you can use non-blocking I/O, asynchronous I/O, select(), poll() etc to determine if the data is available. If it is, reading the data is essentially just

Re: [Haskell-cafe]Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Glynn Clements
Keean Schupke wrote: read. I don't see the problem... (Okay, I can see that if select lies, and the read takes a long time you might miss the next scheduling timeslot - but as far as I am aware select doesn't lie, and read will return immediately if select says there is data

[Haskell-cafe] lex

2005-01-20 Thread Daniel Fischer
Hi, does anybody know, why 'lex' isn't faithful to the Haskell-syntax? Since it isn't difficult to make it ignore comments, handle qualified names and recognize octal/hexadecimal literals (the system, be it hugs or ghc, does it, and I filled in the required code this evening, so for a good

[Haskell-cafe] Can't do basic time operations with System.Time

2005-01-20 Thread John Goerzen
Hi, I have a simple desire. I have a string that I need to parse as a date/time string in the local timezone, then convert it to standard seconds-since-epoch format. This is trivial in C, Perl, Python, etc. but seems impossible to do reliably in Haskell. I'm hoping someone can tell me where

Re: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Ben Rudiak-Gould
Glynn Clements wrote: Keean Schupke wrote: Why is disk a special case? With slow streams, where there may be an indefinite delay before the data is available, you can use non-blocking I/O, asynchronous I/O, select(), poll() etc to determine if the data is available. [...] With files or block

[Haskell-cafe] Re: [Haskell] Implicit parallel functional programming

2005-01-20 Thread Ben Lippmeier
Satnam Singh wrote: Ample looks interesting. What license does it use? I had a quick look over the source and can't find anything. Is there a port to Windows or does it not do any OS specific UI/graphics? By default, we're releasing it under GPL. I guess I should place a copy of the license

[Haskell-cafe] weird behavior using HUnit

2005-01-20 Thread Frédéric Gobry
Hello, I just experienced a weird problem while using HUnit. My code (a simple apache log analyser) used to run in constant space (thanks to the good suggestions and examples I received from the list :-)), and I wanted to add some unit tests. To my great surprise, the code started to eat up lots

Re: [Haskell-cafe] Reading images

2005-01-20 Thread Adrian Hey
On Thursday 20 Jan 2005 7:35 pm, Dmitri Pissarenko wrote: Hello! I need to write a function in Haskell, which 1) reads a greyscale image (for instance, in JPEG, PNG or the like) and 2) transforms it into a n X m matrix A, where Aij contains an integer value (in the range 0 to 255). That

Re: [Haskell-cafe] Reading images (PGM)

2005-01-20 Thread Ketil Malde
Greg Buchholz [EMAIL PROTECTED] writes: I need to write a function in Haskell, which 1) reads a greyscale image (for instance, in JPEG, PNG or the like) and If you can specify any image format you want, and you're not concerned with efficiency, you can't beat the simplicity of the