Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-21 Thread Friedrich
Udo Stenzel [EMAIL PROTECTED] writes: Friedrich wrote: Ok to be more concrete is the laziness hidden here? check_line line sum count = let match = matchRegex regexp line in case match of Just strs - (sum + read (head strs) :: Integer, count + 1)

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-21 Thread Friedrich
Udo Stenzel [EMAIL PROTECTED] writes: Friedrich wrote: Ok to be more concrete is the laziness hidden here? check_line line sum count = let match = matchRegex regexp line in case match of Just strs - (sum + read (head strs) :: Integer, count + 1)

RE: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-21 Thread Simon Peyton-Jones
. We don't want to force subscribers to the main Haskell list to unsubscribe. Thanks Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On | Behalf Of Friedrich | Sent: 21 October 2008 08:18 | To: haskell@haskell.org | Subject: Re: [Haskell] Probably a trivial

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-20 Thread Chris Eidhof
I think it might be more appropriate to move this discussion to haskell-cafe. On 19 okt 2008, at 17:24, Friedrich wrote: Learn to love types: one of the neat things about Haskell is that if you can write down the type of a function then you have usually done 90% of the work of writing the

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-20 Thread Udo Stenzel
Friedrich wrote: Ok to be more concrete is the laziness hidden here? check_line line sum count = let match = matchRegex regexp line in case match of Just strs - (sum + read (head strs) :: Integer, count + 1) Nothing - (sum, count) Yes, part of

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-20 Thread Udo Stenzel
Friedrich wrote: Taral [EMAIL PROTECTED] writes: Wow, talk about doing everything by hand. :) There are a lot of utility functions that make your life easier. Try this: Given a strict pair, it should work: import Control.Monad import Data.Char import Data.List import

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-20 Thread Friedrich
Thanks, I just figured out that I run out of file descriptors with reading them all at once. But I probably can try the countDownloads function. We'll see how that works. Regards Friedrich ___ Haskell mailing list Haskell@haskell.org

[Haskell-cafe] Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-20 Thread Chris Eidhof
I think it might be more appropriate to move this discussion to haskell-cafe. On 19 okt 2008, at 17:24, Friedrich wrote: Learn to love types: one of the neat things about Haskell is that if you can write down the type of a function then you have usually done 90% of the work of writing the

Re: [Haskell-cafe] Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-20 Thread Jason Dagit
On Sun, Oct 19, 2008 at 11:39 PM, Chris Eidhof [EMAIL PROTECTED] wrote: I think it might be more appropriate to move this discussion to haskell-cafe. On 19 okt 2008, at 17:24, Friedrich wrote: Learn to love types: one of the neat things about Haskell is that if you can write down the type

[Haskell-cafe] Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-20 Thread Achim Schneider
Jason Dagit [EMAIL PROTECTED] wrote: Something I have noticed about myself now that I can think in types to some degree is that reading the documentation for apis in non-typeful languages, I'll pick on python, is now harder! Well, something I have noticed is a definitive lack of documentation

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Friedrich
Marshall Beddoe [EMAIL PROTECTED] writes: Also, read some chapters from here: http://book.realworldhaskell.org/read/ Indispensable examples for writing higher performance log processing code. I hope this book will soon be send out. I ordered my copy of course ;-) Howerver even if Strings

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Brandon S. Allbery KF8NH
On 2008 Oct 19, at 2:07, Friedrich wrote: Howerver even if Strings are bad I can not see why they are hanging around so long. I open a file a read it line by line and I close the file so all read string are garbage and getting rid of them should not be that hard or should it? If your code is

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Brandon S. Allbery KF8NH
On 2008 Oct 19, at 2:26, Friedrich wrote: Paul Johnson [EMAIL PROTECTED] writes: (By the way, putting in the top level type declarations helps a lot when you make a mistake.) Well I have my problems with that. Probably it comes from using Languages like Ruby and my special dislike of typing

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Friedrich
Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: On 2008 Oct 19, at 2:07, Friedrich wrote: Howerver even if Strings are bad I can not see why they are hanging around so long. I open a file a read it line by line and I close the file so all read string are garbage and getting rid of them

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Brandon S. Allbery KF8NH
On 2008 Oct 19, at 11:18, Friedrich wrote: Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: On 2008 Oct 19, at 2:07, Friedrich wrote: Howerver even if Strings are bad I can not see why they are hanging around so long. I open a file a read it line by line and I close the file so all read

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Friedrich
Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: On 2008 Oct 19, at 2:26, Friedrich wrote: Paul Johnson [EMAIL PROTECTED] writes: (By the way, putting in the top level type declarations helps a lot when you make a mistake.) Well I have my problems with that. Probably it comes from using

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Friedrich
Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: On 2008 Oct 19, at 2:07, Friedrich wrote: Howerver even if Strings are bad I can not see why they are hanging around so long. I open a file a read it line by line and I close the file so all read string are garbage and getting rid of them

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Brandon S. Allbery KF8NH
On 2008 Oct 19, at 11:24, Friedrich wrote: Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: The relationship between types and proofs is especially obvious in Haskell. And proofs aren't merely mathematical entities, they're expressions of what you want to accomplish: if you can type your

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Brandon S. Allbery KF8NH
On 2008 Oct 19, at 11:25, Friedrich wrote: Ok to be more concrete is the laziness hidden here? check_line line sum count = let match = matchRegex regexp line in case match of Just strs - (sum + read (head strs) :: Integer, count + 1) Nothing - (sum,

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Chry Cheng
Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: Laziness is a double-edged sword. Perhaps the following page from Haskell Wiki would serve to enlighten more: http://haskell.org/haskellwiki/Foldr_Foldl_Foldl%27? This really made it clear to me how laziness can sometimes be a bad thing.

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Till Mossakowski
Chry Cheng schrieb: Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: Laziness is a double-edged sword. Perhaps the following page from Haskell Wiki would serve to enlighten more: http://haskell.org/haskellwiki/Foldr_Foldl_Foldl%27? This really made it clear to me how laziness can

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Paul Johnson
Friedrich wrote: Ok to be more concrete is the laziness hidden here? check_line line sum count = let match = matchRegex regexp line in case match of Just strs - (sum + read (head strs) :: Integer, count + 1) Nothing - (sum, count) Probably.

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Friedrich
Taral [EMAIL PROTECTED] writes: On Sat, Oct 18, 2008 at 1:50 AM, Friedrich [EMAIL PROTECTED] wrote: I've written just a few programs in Haskell one in a comparison for a task I had nearly daily. The code analyzes Apache logs and picks some certain stuff from it and after that calculates a

[Haskell-cafe] Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-19 Thread Paul Johnson
Friedrich wrote: Paul Johnson [EMAIL PROTECTED] writes: [...] Because file reading is lazy, each line is only read when it is to be processed, and then gets reaped by the garbage collector. So it all runs in constant memory. Would you mind to elaborate a bit about it. What's so

Re: [Haskell] Probably a trivial thing for people knowing Haskell

2008-10-18 Thread Paul Johnson
Friedrich wrote: I've written just a few programs in Haskell one in a comparison for a task I had nearly daily. The first thing I notice is that this is clearly a direct translation from something like Perl. Thats understandable, but I'd suggest rewriting it with something like this