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

2008-10-21 Thread Simon Peyton-Jones
ivial thing for people knowing Haskell | | Udo Stenzel <[EMAIL PROTECTED]> writes: | | >> Friedrich wrote: | >> >Ok to be more concrete is the laziness "hidden" here? | >> > | >> >check_line line sum count = | >> >le

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,

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,

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 http://www.haskell

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 S

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, co

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

2008-10-19 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 cod

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 t

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) Probab

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 somet

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 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 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 y

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

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 co

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 s

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

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 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-18 Thread Friedrich
Paul Johnson <[EMAIL PROTECTED]> writes: > 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

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

2008-10-18 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 Stri

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 (unte

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

2008-10-18 Thread Chris Kuklewicz
H mm.. The totals in "sum" and "count" are not computed until printed. This is too lazy. You start with '0' and (+) things to it, but never examine or force the value, so man many (+) thunks are built up in memory. If you use bang patterns then the change can be made here, to !sum !count:

[Haskell] Probably a trivial thing for people knowing Haskell

2008-10-18 Thread Friedrich
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 bit around with it. Here's the code module Main where import System import System.IO import System.Direct