Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Joel Reymont
This should not be the case. The amount of work is the same regardless and the issues seem to be with _timing_. Passing in trace that writes to the screen with a lock sort of slows things down. I encourage you to actually build the code and see it for yourself. Thanks, Joel On Dec

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Ketil Malde
Neil Mitchell [EMAIL PROTECTED] writes: I would have actually said Hugs, and especially the Windows front end WinHugs was a lot more suitable for beginners than GHC, but the wiki page very much gives the other impression. Which page are you referring to? I went to look, but couldn't find any

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Tomasz Zielonka
On Wed, Dec 21, 2005 at 10:33:12AM +, Joel Reymont wrote: My guess is that without tweaks the threads allocate more, which increases the pressure on GC. Try to analyze the GC stats with and without tweaks. This should not be the case. The amount of work is the same regardless and the

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Robin Green wrote: Henning Thielemann wrote: Starting with IO in Haskell is like starting LaTeX with rotating text and making it colorful. Not at all! Indeed IO _is_ complicated regardless of whether it is modelled by Monads in Haskell or differently in other

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera
Robin Green wrote: Whilst localising IO to a small part of the program is generally a good idea, beginners should not be scared off by the thought that IO in Haskell is so hard it has to be covered on page 94. This is not the case. It should be introduced on page 1. As a newbie... I'll agree

[Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Daniel Carrera
Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't really understand monads yet. Is there someone who might explain this

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Daniel Carrera wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't really understand

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Udo Stenzel
Robin Green wrote: If people want Haskell to be treated as a practical language, not just something for doing academic teaching and research with, it should be taught as a practical language - which means that things like IO and space/time usage come to the forefront. Strange, I always

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Henning Thielemann
On Wed, 21 Dec 2005, Robin Green wrote: Henning Thielemann wrote: Starting with IO in Haskell is like starting LaTeX with rotating text and making it colorful. Not at all! Indeed IO _is_ complicated regardless of whether it is modelled by Monads in Haskell or differently in other

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Henning Thielemann
On Wed, 21 Dec 2005, Creighton Hogg wrote: I agree with this wholeheartedly. When I first started playing with Haskell, some of the tutorials made it look like it was very difficult to do anything practical with it because doing real input and output seemed like an advanced topic. The

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera
Udo Stenzel wrote: Strange, I always thought predictable, understandable and above all correct code would be the primary goal, with small and quick code coming later. Depends on what you mean by quick and small. Do you mean that the program should execute fast and have a small memmory

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera
Henning Thielemann wrote: IO is always complicated: I have never once thought it was complicated. All I've ever needed are print() and readLine() and those shouldn't be complicated IMO. And I wouldn't want to wait for page 120 to learn how to do that. My programs are not going to be useful

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Cale Gibbard
On 21/12/05, Daniel Carrera [EMAIL PROTECTED] wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't really

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Henning Thielemann wrote: On Wed, 21 Dec 2005, Creighton Hogg wrote: I agree with this wholeheartedly. When I first started playing with Haskell, some of the tutorials made it look like it was very difficult to do anything practical with it because doing real

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Cale Gibbard
On 21/12/05, Cale Gibbard [EMAIL PROTECTED] wrote: On 21/12/05, Daniel Carrera [EMAIL PROTECTED] wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Cale Gibbard
On 21/12/05, Daniel Carrera [EMAIL PROTECTED] wrote: Henning Thielemann wrote: IO is always complicated: I have never once thought it was complicated. All I've ever needed are print() and readLine() and those shouldn't be complicated IMO. And I wouldn't want to wait for page 120 to learn

Re: [Haskell-cafe] Tutorial uploaded

2005-12-21 Thread Ketil Malde
Paul Moore [EMAIL PROTECTED] writes: One thing I'd consider adding is something along the lines of a section: == So how do I write Hello, world? == I've gone and done it. I've perhaps been heavy handed on the original page, so feel free to complain and/or fix it. -k -- If I haven't seen

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Daniel Carrera
Thanks for all the help. I think things are much clearer now. And this bit: main = do putStrLn Hello, what is your name? name - getLine putStrLn (Hello, ++ name ++ !) Looks quite straight forward. I just wrote my very first IO program with Haskell: --//-- main = do

[Haskell-cafe] IO

2005-12-21 Thread Ralf Hinze
Interesting discussion ... I don't think it is necessary/desirable to relegate IO to `chapter 14'. First of all, IO is handled differently in Haskell as the language designers quite successfully resisted the temptation of impurity. However, you don't have to understand the full implications of

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread John Hughes
-- Message: 1 Date: Wed, 21 Dec 2005 10:48:08 + From: Robin Green [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] Re: Tutorial uploaded Beginners should start with non-monadic functions in order to later avoid IO

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Cale Gibbard
On 21/12/05, Daniel Carrera [EMAIL PROTECTED] wrote: Thanks for all the help. I think things are much clearer now. And this bit: main = do putStrLn Hello, what is your name? name - getLine putStrLn (Hello, ++ name ++ !) Looks quite straight forward. I just wrote my

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Daniel Carrera wrote: Thanks for all the help. I think things are much clearer now. And this bit: main = do putStrLn Hello, what is your name? name - getLine putStrLn (Hello, ++ name ++ !) Looks quite straight forward. I just wrote my very

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Henning Thielemann
On Wed, 21 Dec 2005, Creighton Hogg wrote: On Wed, 21 Dec 2005, Henning Thielemann wrote: The drawback is that I saw many Haskell programs implemented with IO read/write functions which could be easily implemented without IO, using laziness. Can you think of any examples of things like

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Wolfgang Jeltsch
Am Dienstag, 20. Dezember 2005 20:07 schrieb Sebastian Sylvan: [...] It's sometimes beneficial to lie a bit when starting out. Perhaps say something like this is a simplified view of things, for all the gory details see chapter 19. Monadic IO is pretty darn cool, sadly that means that many

[Haskell-cafe] Re: [Haskell] A simple server (or how to do io).

2005-12-21 Thread Einar Karttunen
On 21.12 01:13, Pupeno wrote: So, I install a signal handler with installHandler... and then ? how do I prevent the program for quiting ? am I missing some kind of event loop here ? Here is a small server program: main = performForkWithUnixySessionStuff work -- this is just for testing,

Re: [Haskell-cafe] Substring replacements

2005-12-21 Thread Daniel Fischer
Am Mittwoch, 21. Dezember 2005 08:18 schrieb Branimir Maksimovic: From: Bulat Ziganshin [EMAIL PROTECTED] Reply-To: Bulat Ziganshin [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Substring replacements Date: Tue, 20 Dec

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 11:48 schrieb Robin Green: [...] If people want Haskell to be treated as a practical language, not just something for doing academic teaching and research with, it should be taught as a practical language - which means that things like IO and space/time usage

[Haskell-cafe] YAHT Tutorial

2005-12-21 Thread Christian Maeder
Folks, I'm surprised Hal's tutorial is so less known. I recommend (and send) it to everybody who asks me. I like that it starts early with some IO and mainly promotes ghc/ghci. Hugs is a good tool as well (and I sometimes use it, too), but ghc is definitively the flagship with better error

RE: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Branimir Maksimovic
From: Joel Reymont [EMAIL PROTECTED] To: Haskell-Cafe Cafe haskell-cafe@haskell.org Subject: [Haskell-cafe] Killer pickler combinators (was Time leak) Date: Wed, 21 Dec 2005 02:39:43 + The original paper is at http://research.microsoft.com/ ~akenn/fun/ picklercombinators.pdf My

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Udo Stenzel
Daniel Carrera wrote: Depends on what you mean by quick and small. Do you mean that the program should execute fast and have a small memmory foot-print? I was referring to Robin's mentioning space/time usage, so yes, that's what I meant. To write interactive Haskell code well, you have to

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Udo Stenzel
Creighton Hogg wrote: On Wed, 21 Dec 2005, Henning Thielemann wrote: The drawback is that I saw many Haskell programs implemented with IO read/write functions which could be easily implemented without IO, using laziness. Can you think of any examples of things like that? Given that

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Udo Stenzel
Robin Green wrote: I meant that for *many* but not all practical programming tasks, IO is important. ...web applications... Ha, wrong! A CGI script only needs getEnv, getContents and putStr, if it has persistent state, it also needs readFile and writeFile. Each of the five is called exactly

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Fischer
Am Mittwoch, 21. Dezember 2005 13:31 schrieb Daniel Carrera: Udo Stenzel wrote: Strange, I always thought predictable, understandable and above all correct code would be the primary goal, with small and quick code coming later. Depends on what you mean by quick and small. Do you mean that

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread David Roundy
On Wed, Dec 21, 2005 at 11:43:42AM +, Daniel Carrera wrote: Hi all, I'm a Haskell newbie and I don't really understand how Haskell deals with functions that really must have side-effects. Like a rand() function or getLine(). I know this has something to do with monads, but I don't

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera
Udo Stenzel wrote: Unless you want to teach people to program as they would do in Basic, that is. I don't know what you mean by that. You will soon. Once you get used to composing functions instead of sequencing actions, you'll appreciate the difference. Ah. Yes, I do think I understand

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Sebastian Sylvan
On 12/21/05, John Hughes [EMAIL PROTECTED] wrote: -- Message: 1 Date: Wed, 21 Dec 2005 10:48:08 + From: Robin Green [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] Re: Tutorial uploaded Beginners should

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera
Daniel Fischer wrote: P.S.: In May, there was a 'Daniel Carrera' around, too. Isn't that a strange coincidence? That was myself, using a different email address. I didn't get too far with Haskell that time, but I remembered that I liked it, so I'm going back to it a bit now. But I'm still a

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Joel Reymont
Cale is a genius! This totally solves the timeouts. Why, though? The lock is only used at the end of the unpickling. Why does it help? On Dec 21, 2005, at 2:56 PM, Cale Gibbard wrote: By the way, when I was doing threadDelays, I meant: trace s = withMVar lock $ const $ threadDelay 20 In

Re[2]: [Haskell-cafe] Substring replacements

2005-12-21 Thread Bulat Ziganshin
Hello Daniel, Wednesday, December 21, 2005, 5:20:18 PM, you wrote: BM I've finally performed test on amd64 and result is a same as on intel. BM KMP always wins. So KMP is best suited for non indexed strings BM and I guess should be used in library as prefered search/replace method. BM This

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Sebastian Sylvan
On 12/21/05, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Dienstag, 20. Dezember 2005 20:07 schrieb Sebastian Sylvan: [...] It's sometimes beneficial to lie a bit when starting out. Perhaps say something like this is a simplified view of things, for all the gory details see chapter 19.

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Joel Reymont
On Dec 21, 2005, at 2:56 PM, Cale Gibbard wrote: By the way, when I was doing threadDelays, I meant: trace s = withMVar lock $ const $ threadDelay 20 In case you didn't try that. I'm trying 5k threads and I still get delays at times. Using thread delay of 1, though. ./unstuff trace.dat

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 13:15 schrieb Creighton Hogg: [...] Monads, I believe, can be just thought of as containers for state. I would say that you are talking especially about the I/O monad here. A monad as such is a rather general concept like a group is in algebra. The important

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Daniel Carrera
Creighton Hogg wrote: x is a String, getLine has type IO String. That's what I was getting at in one of my last e-mails. Hmm... let's see if I understand: * getLine() has type IO String. * The - will convert an IO String to a plain String * So if I do x - getLine() then x has the type

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Sebastian Sylvan
On 12/21/05, Wolfgang Jeltsch [EMAIL PROTECTED] wrote: Am Mittwoch, 21. Dezember 2005 11:48 schrieb Robin Green: [...] If people want Haskell to be treated as a practical language, not just something for doing academic teaching and research with, it should be taught as a practical

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread David Barton
Wolfgang Jeltsch writes: - Original Message - Am Mittwoch, 21. Dezember 2005 13:15 schrieb Creighton Hogg: [...] Monads, I believe, can be just thought of as containers for state. I would say that you are talking especially about the I/O monad here. A monad as such is a rather

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera
Sebastian Sylvan wrote: Well, I certainly disagree there. I'm not advocating going into a full-blown explanation of monads, just enough to actually be able to write a real stand-alone program after the first chapter. They only need to know that do-notation is for sequencing computations, and (-)

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera
Sebastian Sylvan wrote: Beginners know that too. In fact, they often think that practical applications need far more IO than they really do! So to insinuate even slightly that Haskell is bad at IO by avoiding it for two thirds of a book, is really going to inforce the idea that Haskell isn't a

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Daniel Carrera wrote: Creighton Hogg wrote: x is a String, getLine has type IO String. That's what I was getting at in one of my last e-mails. Hmm... let's see if I understand: * getLine() has type IO String. * The - will convert an IO String to a plain String

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Joel Reymont
The other thing worth noting is that by inserting a lock with a thread delay we are fooling ourselves. While the individual pickling time goes down, the threads are slowed down overall. Assuming that an external source was waiting for the unpickled packet _that_ source would get a timeout!

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Bill Wood
On Wed, 2005-12-21 at 13:10 +0100, Udo Stenzel wrote: . . . tutorial. Before that, IO should be restricted to the EVA principle (Eingabe, Verarbeitung, Ausgabe == Input, Processing, Output). It was a good principle in the 60s, and it still is. Unless you want to teach people to program

[Haskell-cafe] Re: When to teach IO (was Tutorial uploaded)

2005-12-21 Thread Bayley, Alistair
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robin Green No, that's not what I meant at all. I meant that for *many* but not all practical programming tasks, IO is important. Games, GUI office applications, database applications, web applications, etc. Compilers

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Sebastian Sylvan
On 12/21/05, Daniel Carrera [EMAIL PROTECTED] wrote: Sebastian Sylvan wrote: Beginners know that too. In fact, they often think that practical applications need far more IO than they really do! So to insinuate even slightly that Haskell is bad at IO by avoiding it for two thirds of a

Re: [Haskell-cafe] Re: When to teach IO (was Tutorial uploaded)

2005-12-21 Thread David Roundy
On Wed, Dec 21, 2005 at 03:47:14PM -, Bayley, Alistair wrote: It's good to start with IO. Reading and writing files, parsing and printing (show and read), talking to databases, GUIs, and networking are more-or-less essential activities, and people want to know early on how to do these

Re: [Haskell-cafe] Substring replacements

2005-12-21 Thread Branimir Maksimovic
From: Daniel Fischer [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: Bulat Ziganshin [EMAIL PROTECTED], Haskell-Cafe@haskell.org KMP is O(m) while straightforward is O(m*n). Where m is the length of the input and n is the length of the searched-for pattern, I think? Yes.

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 16:30 schrieb Daniel Carrera: [...] Would it be fair to say that do-blocks are imperative blocks in an otherwise functional program? Not really. do expressions are (normally) equivalent to expressions containing applications of (=) and/or (). If the monad you

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Donn Cave
On Wed, 21 Dec 2005, Udo Stenzel wrote: [... re pitfalls of IO for the beginner ] Here's another one: I've heard a fellow claim, Haskell is basically unsuitable to implement a compiler, because Haskell is weak at IO and everything needs IO, the lexer, the preprocessor, the parser, the

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Branimir Maksimovic
From: Joel Reymont [EMAIL PROTECTED] To: Branimir Maksimovic [EMAIL PROTECTED] CC: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Killer pickler combinators (was Time leak) Date: Wed, 21 Dec 2005 14:51:42 + I'm not sure I buy this. Again, this helps: {-# NOINLINE lock #-} lock ::

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 16:28 schrieb David Barton: Wolfgang Jeltsch writes: - Original Message - Am Mittwoch, 21. Dezember 2005 13:15 schrieb Creighton Hogg: [...] Monads, I believe, can be just thought of as containers for state. I would say that you are talking

[Haskell-cafe] Fwd: Monads and pedagogy (Functions with side-effects?)

2005-12-21 Thread Greg Woodhouse
Oops...meant to send this to the list, too. --- Greg Woodhouse [EMAIL PROTECTED] wrote: Date: Wed, 21 Dec 2005 09:42:44 -0800 (PST) From: Greg Woodhouse [EMAIL PROTECTED] Subject: Monads and pedagogy (Functions with side-effects?) To: David Barton [EMAIL PROTECTED] --- David Barton

Re: [Haskell-cafe] comprehension generators from IO [a]'s ?

2005-12-21 Thread Bulat Ziganshin
Hello Steve, Monday, December 19, 2005, 10:42:19 PM, you wrote: SH What I'm after is something like: SH -- (psuedo-code) SH [(b,c,d) | SHb - getDirectoryContents a_dir, SHc - getDirectoryContents (a_dir ++ / ++ b), SHd - getDirectoryContents (a_dir ++ / ++ b

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Greg Woodhouse
--- Wolfgang Jeltsch [EMAIL PROTECTED] wrote: I think Phil Wadler said it best when he said that a monad is a *computation*. To be honest, I'm still struggling with the monad concept myself. Oh sure, I can read the definition and it makes sense. But I'm still missing that aha! moment when

[Haskell-cafe] Problems with square root...

2005-12-21 Thread Daniel Carrera
Hey, The sqrt function is not doing what I want. This is what I want: round sqrt(2) The problem is that sqrt() returns a Floating value and round wants a ReacFrac: --//-- *Main round sqrt(2) interactive:1:0: No instances for (RealFrac (a - a), Integral (t - a1)) arising from use of

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Udo Stenzel
Donn Cave wrote: Meanwhile, that fellow evidently didn't write any compiler in Haskell at all. Better a C++ program than a Haskell program that offends you? Oh no, he actually wrote something disgusting built mostly out of regexes in Perl. I don't think it even works, and I don't think I

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Daniel Carrera
Daniel Carrera wrote: Hey, The sqrt function is not doing what I want. This is what I want: round sqrt(2) Sigh... never fails. Spend an hour trying to solve a problem, and a minute after you write to the list you find the solution. I need brackets around sqrt. I'm surprised though. I don't

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Radu Grigore
On 12/21/05, Daniel Carrera [EMAIL PROTECTED] wrote: round sqrt(2) I don't understand why it dosn't work without brackets. Function application is left associative in Haskell. -- regards, radu http://rgrig.blogspot.com/ ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Jon Fairbairn
On 2005-12-21 at 18:10GMT Daniel Carrera wrote: Daniel Carrera wrote: Hey, The sqrt function is not doing what I want. This is what I want: round sqrt(2) Sigh... never fails. Spend an hour trying to solve a problem, and a minute after you write to the list you find the solution.

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Hal Daume III
Sigh... never fails. Spend an hour trying to solve a problem, and a minute after you write to the list you find the solution. I need brackets around sqrt. I'm surprised though. I don't understand why it dosn't work without brackets. because x y z parses as (x y) z, so round sqrt 2 parses

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Daniel Carrera
Radu Grigore wrote: I don't understand why it dosn't work without brackets. Function application is left associative in Haskell. Ah. I implicitly assumed right-association (it works in Perl ;) ) Thanks. -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Tomasz Zielonka
On Wed, Dec 21, 2005 at 06:10:56PM +, Daniel Carrera wrote: Daniel Carrera wrote: Hey, The sqrt function is not doing what I want. This is what I want: round sqrt(2) Sigh... never fails. Spend an hour trying to solve a problem, and a minute after you write to the list you find the

Re: [Haskell-cafe] Re: First steps in Haskell

2005-12-21 Thread Bulat Ziganshin
Hello Alistair, Tuesday, December 20, 2005, 1:13:50 PM, you wrote: BA And there's this interesting site, which demos a interpreter running in BA your browser it's a neat idea! I/O-stripped version of hugs can be runned in such way btw, i send to newcomers the following recommendations:

Re: [Haskell-cafe] Re: Battling time leaks

2005-12-21 Thread Bulat Ziganshin
Hello Joel, Tuesday, December 20, 2005, 3:38:17 PM, you wrote: It looks like I successfully squashed my time leaks and moving my serialization to Ptr Word8 got me as close to the metal as possible. I'm still getting wierd results, though, and they look like a time leak. ORANGE ALERT:

[Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Peter Simons
Some example for writing a text the IO oriented way: do putStrLn bla replicateM 5 (putStrLn blub) putStrLn end whereas the lazy way is putStr (unlines ([bla] ++ replicate 5 blub ++ [end])) Um, maybe it's just me, but I think the first program is far superior to the

Re: [Haskell-cafe] Re: Battling time leaks

2005-12-21 Thread Joel Reymont
On Dec 20, 2005, at 1:38 PM, Bulat Ziganshin wrote: can you say what it exactly means? we are not mastered in your code. some common explanation like my program takes 6 seconds to deserialize 50kb of data on Pentium4/3ghz will be more understabdable That's why I posted the code at

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Tomasz Zielonka
On Wed, Dec 21, 2005 at 07:35:28PM +0100, Peter Simons wrote: Some example for writing a text the IO oriented way: do putStrLn bla replicateM 5 (putStrLn blub) putStrLn end whereas the lazy way is putStr (unlines ([bla] ++ replicate 5 blub ++ [end])) Um, maybe

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Mark Goldman
nitpicky detail: () - Parenthesis {} - Braces [] - Brackets Sorry to be pedantic, but using the wrong terminology confuses me and I'm sure others as well. On 12/21/05, Daniel Carrera [EMAIL PROTECTED] wrote: Daniel Carrera wrote: Hey, The sqrt function is not doing what I want. This is

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Philippa Cowderoy
On Wed, 21 Dec 2005, Peter Simons wrote: Some example for writing a text the IO oriented way: do putStrLn bla replicateM 5 (putStrLn blub) putStrLn end whereas the lazy way is putStr (unlines ([bla] ++ replicate 5 blub ++ [end])) Um, maybe it's just me, but I

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Jared Updike
MG () - Parenthesis MG {} - Braces MG [] - Brackets MG Sorry to be pedantic, but using the wrong terminology confuses me and MG I'm sure others as well. This is true for Haskell, but Daniel is correct if he is calling () Brackets because they are, in British English, right? (Just like '.' is a

Re: [Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Wolfgang Jeltsch
Am Mittwoch, 21. Dezember 2005 19:02 schrieben Sie: [...] You (or, rather the processor) don't execute instructions to write Hello in same way as, say, adding 2 and 2. Exactly! Rather, you add writing this string to a to do list and wait for a driver to respond to an interrupt, pick up the

[Haskell-cafe] Re: problems with square roots...

2005-12-21 Thread Scherrer, Chad
From: Daniel Carrera [EMAIL PROTECTED] Hey, The sqrt function is not doing what I want. This is what I want: round sqrt(2) --- Daniel, A lot of Haskell folks like to avoid parentheses as much as possible, and there's a really

Re: [Haskell-cafe] Re: problems with square roots...

2005-12-21 Thread Creighton Hogg
On Wed, 21 Dec 2005, Scherrer, Chad wrote: From: Daniel Carrera [EMAIL PROTECTED] Hey, The sqrt function is not doing what I want. This is what I want: round sqrt(2) --- Daniel, A lot of Haskell folks like to avoid

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Benjamin Franksen
On Wednesday 21 December 2005 18:48, Udo Stenzel wrote: Donn Cave wrote: Meanwhile, that fellow evidently didn't write any compiler in Haskell at all. Better a C++ program than a Haskell program that offends you? Oh no, he actually wrote something disgusting built mostly out of regexes

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Cale Gibbard
Well, yes. I think that part of the problem you're having is that the threads compete very highly, and some eventually get ignored for longer than the timeouts. The reason why the (withMVar lock $ const $ putStrLn s) helped in the first place was not so much because of any evaluation of s (we

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Joel Reymont
I don't want any kind of locking, true. I need all bots to respond in time otherwise the poker server will sit them out. Eliminating the timeout on pickling does not eliminate the timeout overall, it just passes it to a different place. One thread will go through serialization quickly but

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Tomasz Zielonka
On Wed, Dec 21, 2005 at 09:30:14PM +, Philippa Cowderoy wrote: On Wed, 21 Dec 2005, Tomasz Zielonka wrote: I don't know how it's done, but when you compile it with 'ghc -O2', the program runs in constant space. Unfortunately with Hugs and GHCi it grows. The live set, or just the

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Cale Gibbard
On 21/12/05, Tomasz Zielonka [EMAIL PROTECTED] wrote: On Wed, Dec 21, 2005 at 07:13:07PM +, Philippa Cowderoy wrote: Try running putStrLn (unlines (repeat hello!)) You may be surprised ;-) Or not ;-) But yes, I should've checked and my comments on how that'll behave

Re: [Haskell-cafe] Killer pickler combinators (was Time leak)

2005-12-21 Thread Sebastian Sylvan
On 12/21/05, Joel Reymont [EMAIL PROTECTED] wrote: I don't want any kind of locking, true. I need all bots to respond in time otherwise the poker server will sit them out. Eliminating the timeout on pickling does not eliminate the timeout overall, it just passes it to a different place. One

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Benjamin Franksen
On Wednesday 21 December 2005 12:17, Daniel Carrera wrote: Robin Green wrote: Whilst localising IO to a small part of the program is generally a good idea, beginners should not be scared off by the thought that IO in Haskell is so hard it has to be covered on page 94. This is not the

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Hal Daume III
As a newbie... I'll agree with Robin. I /did/ think that IO in Haskell was probably very difficult because it's covered in page 94. I skimmed through YAHT and IO is covered wyyy deep into the document. I haven't read that section yet, but there is a lot of content and to me it looked

Re: [Haskell-cafe] Problems with square root...

2005-12-21 Thread Daniel Carrera
Mark Goldman wrote: nitpicky detail: () - Parenthesis {} - Braces [] - Brackets Sorry to be pedantic, but using the wrong terminology confuses me and I'm sure others as well. Being pedantic can be fun :) The Macquarie Dictionary, which is the official dictionary in Australia, says that ()

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread John Meacham
noise The truth is, Haskell friggen rocks at IO compared to imperative languages. We are all spoiled and see IO in haskell as ugly because we have been exposed to the pure functional goodness of the rest of haskell. but teaching haskell as a better impertive language than imperative ones from the

Re: [Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread Benjamin Franksen
On Wednesday 21 December 2005 16:49, Sebastian Sylvan wrote: On 12/21/05, Daniel Carrera [EMAIL PROTECTED] wrote: Sebastian Sylvan wrote: Beginners know that too. In fact, they often think that practical applications need far more IO than they really do! So to insinuate even slightly

[Haskell-cafe] Re: Tutorial uploaded

2005-12-21 Thread S Koray Can
Daniel Carrera wrote: As a newbie... I agree that a newbie should be able to write this fairly early on: main = do x - getLine() putStrLn (The answer is ++ show(fib(read(x I'd agree for some definition of 'early'. I'll elaborate: This entire discussion is about 'breaking