[Haskell-cafe] parsebinaryoperations

2007-12-09 Thread Ryan Bloor
hi I have a function parseInt... which needs an error guard for when the input is not an Int. parseInt :: ParserparseInt [] = []parseInt xs = let (digits, rest) = span isDigit (removeSpace xs)in [(EInt (read digits), removeSpace rest)] Also... I have a function that does

[Haskell-cafe] ST Monad - what's wrong?

2007-12-09 Thread Nicu Ionita
Hi, I'm trying to use the ST monad in order to turn an almost pure function into a pure one: reading a precalculated list of primes into a prime set. But the following code brings an error: primes :: Set Integer primes = runST $ getPrimes primes10h7.txt getPrimes :: String - (forall s. ST s

[Haskell-cafe] AW: ST Monad - what's wrong?

2007-12-09 Thread Nicu Ionita
Ok, solved, the use of ($) was the problem. I changed it primes :: Set Integer primes = runST (getPrimes primes10h7.txt) and it compiles (and works too). Nicu -Ursprüngliche Nachricht- Von: Nicu Ionita [mailto:[EMAIL PROTECTED] Gesendet: Sonntag, 9. Dezember 2007 12:12 An:

Re: [Haskell-cafe] Problem with Gtk2hs

2007-12-09 Thread Andrew Coppin
Stefan O'Rear wrote: On Sat, Dec 08, 2007 at 08:33:36PM +, Andrew Coppin wrote: I just spent the evening writing a library that's a thin layer over Gtk2hs. It took an age to get it to compile, but eventually it worked. Yay! When I ran it, I got this: Test2:

Re: [Haskell-cafe] ST Monad - what's wrong?

2007-12-09 Thread pepe
The typechecker in 6.6.1 gets confused by the ($) and loses track of the 'freeness' of s (the thread variable) . The same code should work fine in 6.8.1, or alternatively in 6.6.1 without the ($). Cheers pepe On 09/12/2007, at 12:11, Nicu Ionita wrote: Hi, I'm trying to use the ST monad

Re: [Haskell-cafe] ST Monad - what's wrong?

2007-12-09 Thread Alfonso Acosta
On Dec 9, 2007 2:39 PM, pepe [EMAIL PROTECTED] wrote: The typechecker in 6.6.1 gets confused by the ($) and loses track of the 'freeness' of s (the thread variable) . The same code should work fine in 6.8.1, or alternatively in 6.6.1 without the ($). True. However, note that the release notes

Re: [Haskell-cafe] ST Monad - what's wrong?

2007-12-09 Thread Alfonso Acosta
True. However, note that the release notes of 6.8.1 encourage not to rely in this new feature because it can change in the feature. I obviously meant in the future, sorry. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] ARM back end?

2007-12-09 Thread Andreas Farre
On Mon, 03 Dec 2007 18:24:10 +0100, Mathieu Boespflug [EMAIL PROTECTED] wrote: On Nov 2, 2007 10:19 PM, nornagon [EMAIL PROTECTED] wrote: On 03/11/2007, Greg Fitzgerald [EMAIL PROTECTED] wrote: Anybody know of an ARM back end for any of the Haskell compilers? If there's an arm-eabi port

Re: [Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-09 Thread Jonathan Cast
On 7 Dec 2007, at 12:39 PM, Dan Weston wrote: Luke Palmer wrote: On Dec 7, 2007 7:57 PM, Luke Palmer [EMAIL PROTECTED] wrote: On Dec 7, 2007 7:41 PM, Dan Weston [EMAIL PROTECTED] wrote: Luke Palmer wrote: You can project the compile time numbers into runtime ones: Yes, that works well if I

Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-09 Thread Conal Elliott
IO is important because you can't write any real program without using it. Ouch! I get awfully discouraged when I read statements like this one. The more people who believe it, the more true it becomes. If you want to do functional programming, instead of imperative programming in a

[Haskell-cafe] Re: [Haskell] IVars

2007-12-09 Thread Conal Elliott
(moving to haskell-cafe) readIVar' :: IVar a - a readIVar' = unsafePerformIO . readIVar so, we do not need readIVar'. it could be a nice addition to the libraries, maybe as unsafeReadIVar or unsafeReadMVar. The same argument applies any to pure function, doesn't it? For instance, a non-IO

Re: [Haskell-cafe] ST Monad - what's wrong?

2007-12-09 Thread Stefan O'Rear
On Sun, Dec 09, 2007 at 12:11:42PM +0100, Nicu Ionita wrote: Hi, I'm trying to use the ST monad in order to turn an almost pure function into a pure one: reading a precalculated list of primes into a prime set. But the following code brings an error: primes :: Set Integer primes =

Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-09 Thread Daniel Fischer
Am Sonntag, 9. Dezember 2007 18:31 schrieb Conal Elliott: IO is important because you can't write any real program without using it. Ouch! I get awfully discouraged when I read statements like this one. The more people who believe it, the more true it becomes. If you want to do

Re: [Haskell-cafe] [OT] A nice organized collection of threads in Haskell-Cafe

2007-12-09 Thread Albert Y. C. Lai
Bryan O'Sullivan wrote: Albert Y. C. Lai wrote: I can't blame you for being not observant. Afterall, this is precisely what I'm alluding to with everyone can haz PC [...] Please don't flame people on the list. I'm flaming an idea, not people on the list.

Re: [Haskell-cafe] ARM back end?

2007-12-09 Thread Lennart Augustsson
There's an ARM backend in hbc. On Nov 2, 2007 8:30 PM, Greg Fitzgerald [EMAIL PROTECTED] wrote: Anybody know of an ARM back end for any of the Haskell compilers? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Do real programs need IO? (was IO is a bad example for Monads)

2007-12-09 Thread Conal Elliott
On Dec 9, 2007 10:07 AM, Daniel Fischer [EMAIL PROTECTED] wrote: Interactive programmes without using IO? Cool :) And how! I think you misunderstood Lennart. Thanks for checking. In this case, I think I understood Lennart fine and that he was saying what you're saying. Would you deny that

Re: [Haskell-cafe] Problem with Gtk2hs

2007-12-09 Thread Felipe Lessa
On Dec 8, 2007 6:33 PM, Andrew Coppin [EMAIL PROTECTED] wrote: (Also, the documentation for Graphics.UI.Gtk.Misc.DrawingArea suggests that you may want to draw a Pixbuf using the pixbufRenderToDrawable function - but GHC complains that this function doesn't exist. I had to use drawPixbuf

Re: [Haskell-cafe] Re: [Haskell] IVars

2007-12-09 Thread Conal Elliott
Thanks, Luke. I'd been unconsciously assuming that the IVar would get written to (if ever) by a thread other than the one doing the reading. (Even then, there could be a deadlock.) - Conal On Dec 9, 2007 9:37 AM, Luke Palmer [EMAIL PROTECTED] wrote: On Dec 9, 2007 5:09 PM, Conal Elliott

Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-09 Thread Lennart Augustsson
Conal, It's true that you can avoid using IO (except for a wrapper) for certain kinds of programs. For instance, if all you want is a String-String function, or some GUI program (you forgot to mention fudgets, which was the first wrapper of this kind) then you can ignore IO and just use a nice

Re: [Haskell-cafe] Re: [Haskell] IVars

2007-12-09 Thread Lennart Augustsson
I would claim that it's fine to use the type readIVar :: IVar a - a if you're willing to give the right semantics to newIVar :: IO (IVar a) The semantics is that sometimes when you create an IVar you'll get one that always returns _|_ when read, sometimes you'll get a proper one. Now if you

Re: [Haskell-cafe] Do real programs need IO? (was IO is a bad example for Monads)

2007-12-09 Thread Lennart Augustsson
Conal, I think TV etc. is fantastic stuff, but that mean that we cannot, say, invoke an external program in Haskell until someone has figured out a composable library for this? I sincerely hope someone will, but the only way we have right now is the ugly IO monad. -- Lennart On Dec 9, 2007

Re: [Haskell-cafe] Do real programs need IO? (was IO is a bad example for Monads)

2007-12-09 Thread Conal Elliott
I think your real point is that some things we still haven't figured out how to express functionally. Right? I would certainly agree with that part. Perhaps you exaggerating when you wrote IO is important because you can't write any real program without using it. Cheers, - Conal On Dec 9, 2007

Re: [Haskell-cafe] Do real programs need IO? (was IO is a bad example for Monads)

2007-12-09 Thread Daniel Fischer
Am Sonntag, 9. Dezember 2007 21:29 schrieb Conal Elliott: I think your real point is that some things we still haven't figured out how to express functionally. Right? That's my point, at least. Currently, AFAIK, the only way to get input and produce output is via the IO monad, so it is de

[Haskell-cafe] help

2007-12-09 Thread Ryan Bloor
hi I have a function parseInt... which needs an error guard for when the input is not an Int. parseInt :: ParserparseInt [] = []parseInt xs = let (digits, rest) = span isDigit (removeSpace xs)in [(EInt (read digits), removeSpace rest)] Also... I have a function that does this...

Parsing integers [was: Re: [Haskell-cafe] help]

2007-12-09 Thread Tim Chevalier
On 12/9/07, Ryan Bloor [EMAIL PROTECTED] wrote: hi I have a function parseInt... which needs an error guard for when the input is not an Int. parseInt :: Parser parseInt [] = [] parseInt xs = let (digits, rest) = span isDigit (removeSpace xs) in [(EInt (read digits),

Fwd: Parsing integers [was: Re: [Haskell-cafe] help]

2007-12-09 Thread Tim Chevalier
[reply forwarded to list] -- Forwarded message -- From: Ryan Bloor [EMAIL PROTECTED] hi sorry for vagueness. I am writing a basic Parser from scratch. So far I have functions; # removeSpaces # match - which checks if a string is a substring of another # orParser which

[Haskell-cafe] binaryop

2007-12-09 Thread Ryan Bloor
hi sorry for vagueness. I am writing a basic Parser from scratch. So far I have functions; # removeSpaces # match - which checks if a string is a substring of another # orParser which combines two parser's abilities # Basic pasrers like... parseInt, parseTrue, parseFalse, parseBoolusing the

Re: [Haskell-cafe] Do real programs need IO? (was IO is a bad example for Monads)

2007-12-09 Thread Conal Elliott
Thanks for the clarification. AFAIK, the only way to get input and produce output is via the IO monad Now you know something different, don't you? FRP, Pan, TV. Also Grapefruit, functional forms, and others I'm not thinking of or don't know about. As for your example, mixing the IO with the

Re: [Haskell-cafe] Re: [Haskell] IVars

2007-12-09 Thread Benja Fallenstein
Hi Conal, On Dec 9, 2007 6:09 PM, Conal Elliott [EMAIL PROTECTED] wrote: readIVar' :: IVar a - a readIVar' = unsafePerformIO . readIVar so, we do not need readIVar'. it could be a nice addition to the libraries, maybe as unsafeReadIVar or unsafeReadMVar. The same argument applies any to

Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-09 Thread Conal Elliott
Thanks. If I'm tracking, your real point is that imperative programming in Haskell is still useful enough to keep around. I agree. I'm still puzzled. Did you understand something I said, or maybe someone else said, as suggesting that imperative programming be removed from Haskell any time

Re: [Haskell-cafe] IO is a bad example for Monads

2007-12-09 Thread Ketil Malde
Daniel Fischer [EMAIL PROTECTED] writes: IO is important because you can't write any real program without using it. Ouch! I get awfully discouraged when I read statements like this one. I think Lennart was referring to that, you HAVE to know a little IO to write programmes, at least

Re: [Haskell-cafe] IO is a bad example for Monads

2007-12-09 Thread Daniel Fischer
Am Sonntag, 9. Dezember 2007 23:35 schrieb Ketil Malde: Daniel Fischer [EMAIL PROTECTED] writes: IO is important because you can't write any real program without using it. Ouch! I get awfully discouraged when I read statements like this one. I think Lennart was referring to that,

Re: [Haskell-cafe] parsebinaryoperations

2007-12-09 Thread Philip Weaver
Maybe you should look into Parsec, a Haskell library for writing parsers. Google should find what you need. - Phil On Dec 9, 2007 1:58 AM, Ryan Bloor [EMAIL PROTECTED] wrote: hi I have a function parseInt... which needs an error guard for when the input is not an Int. parseInt :: Parser

RE: [Haskell-cafe] Point and link

2007-12-09 Thread Tim Docker
Andrew Coppin wrote: Such a GUI would be cool for a number of projects. It still needs to exist first. ;-) I don't think anyone has mentioned this: http://haskell.org/Blobs which I haven't used, though the screenshots look good. ___ Haskell-Cafe

Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-09 Thread Lennart Augustsson
I doubt all imperative programming will be banished from Haskell anytime soon. I really, really wish we had all the nice abstractions in place already, but we just don't. You can't write any program in Haskell without using IO, because the type of main involves IO. And currently I believe that

Re: [Haskell-cafe] Do real programs need IO? (was IO is a bad example for Monads)

2007-12-09 Thread Lennart Augustsson
Maybe I'm exaggerating, but it's true for 96% of all programs. (96% is with a :-)) I did not express anything that was meant to be a perpetual truth, only best practice at the moment. For a living I write programs that are almost without interaction with the outside world. Still, I need a to

Re: [Haskell-cafe] Problem with Gtk2hs

2007-12-09 Thread Duncan Coutts
On Sat, 2007-12-08 at 13:08 -0800, Stefan O'Rear wrote: On Sat, Dec 08, 2007 at 08:33:36PM +, Andrew Coppin wrote: I just spent the evening writing a library that's a thin layer over Gtk2hs. It took an age to get it to compile, but eventually it worked. Yay! When I ran it, I got

[Haskell-cafe] ANNOUNCE: xmonad 0.5: a tiling window manager

2007-12-09 Thread Don Stewart
The xmonad dev team is pleased to announce the 0.5 release of xmonad! http://xmonad.org xmonad is a tiling window manager for X. Windows are arranged automatically to tile the screen without gaps or overlap, maximising screen use. Window manager features are

Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-09 Thread Conal Elliott
It so happens that Haskell currently insists on main :: IO (). That's simple to fix, however, and with great pay-off. Suppose instead main :: TV a (where I'm omitting the other TV type args for simplicity.) Then a program could not only be run, but also composed with other programs. They could

Re: [Haskell-cafe] [OT] A nice organized collection of threads in Haskell-Cafe

2007-12-09 Thread Vimal
Hi, Yes, I looked into it as per the Mailman documentation. I was wondering if there was a module already that could do it, to avoid some work :) What is the difference between In-Reply-To and References? And the list of posts was just the beginning. Each post would have sufficient information

Re: [Haskell-cafe] [OT] A nice organized collection of threads in Haskell-Cafe

2007-12-09 Thread Vimal
And looks like this post has gone on a tangent :D Vimal And looks like this _thread_ has gone on a tangent :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: [Haskell] IVars

2007-12-09 Thread Conal Elliott
Thanks. I don't know for what uses of IVars the difference in expressiveness is helpful, but now I get that the difference is there. Cheers, - Conal On Dec 9, 2007 2:08 PM, Benja Fallenstein [EMAIL PROTECTED] wrote: Hi Conal, On Dec 9, 2007 6:09 PM, Conal Elliott [EMAIL PROTECTED] wrote:

[Haskell-cafe] Need help please.

2007-12-09 Thread Ryan Bloor
hi I am writing a basic Parser from scratch. So far I have functions;# removeSpaces# match - which checks if a string is a substring of another# orParser which combines two parser's abilities# Basic pasrers like... parseInt, parseTrue, parseFalse, parseBoolusing the orParser on True and

[Haskell-cafe] Re: Do real programs need IO? (was IO is a bad example for Monads)

2007-12-09 Thread Maurí­cio
(...) Would you deny that any useful programme has to do at least some of the following: -accept programme arguments at invocation -get input, be it from a keyboard, mouse, reading files, pipes... -output a result or state info, to the monitor, a file, a pipe... === As long

Re: [Haskell-cafe] What is the role of $!?

2007-12-09 Thread David Fox
Argh, that last sentence should read the file is left alone.. On Dec 9, 2007 10:15 PM, David Fox [EMAIL PROTECTED] wrote: Here is a practical example I ran into a few days ago. With this expression: writeFile path (compute text) the file at path would be overwritten with an empty file