[Haskell-cafe] CDouble type coercion

2006-05-14 Thread SevenThunders
I am new to Haskell and found myself in a bind concerning the use of the C types, CDouble in particular. I extract a CDouble via it's pointer from a StorableArray. Since the array must interface with C the elements of the array must be CDouble. Now I'd like to use Text.Printf to format print

Re: [Haskell-cafe] [newbie] processing large logs

2006-05-14 Thread Eugene Crosser
Udo Stenzel wrote: Eugene Crosser wrote: This is my program: module Main where import Data.Map main = printMax . (foldr processLine empty) . lines = getContents processLine line map = insertWith (\new old - new + old) line 1 map printMax map = putStrLn $ show $ foldWithKey

Re: [Haskell-cafe] [newbie] processing large logs

2006-05-14 Thread Antti-Juhani Kaijanaho
Eugene Crosser wrote: Having read Yet another Haskell tutorial (note on p.20), doesn't foldl have to read the complete list before it can start processing it (beginning from the last element)? As opposed to foldr that can fetch elements one by one as they are needed? They're complementary.

Re: [Haskell-cafe] [newbie] processing large logs

2006-05-14 Thread Udo Stenzel
Eugene Crosser wrote: Having read Yet another Haskell tutorial (note on p.20), doesn't foldl have to read the complete list before it can start processing it (beginning from the last element)? As opposed to foldr that can fetch elements one by one as they are needed? Both foldl and foldr

[Haskell-cafe] foldl to foldl' , ok ; but with foldM ?

2006-05-14 Thread minh thu
Hi, I know the question is raised often but i cannot find the answer. In a previous mail, I was said to use foldl' instead of foldl and it worked really well : acc1 values = foldl1' (+) values How is foldl' defined ? I have two other related questions : What if I want to write something

Re: [Haskell-cafe] [newbie] processing large logs

2006-05-14 Thread Eugene Crosser
Udo Stenzel wrote: Eugene Crosser wrote: Having read Yet another Haskell tutorial (note on p.20), doesn't foldl have to read the complete list before it can start processing it (beginning from the last element)? As opposed to foldr that can fetch elements one by one as they are needed?

Re: [Haskell-cafe] [newbie] processing large logs

2006-05-14 Thread Antti-Juhani Kaijanaho
Eugene Crosser wrote: Anyway, I understand that you used 'seq' in your example as a way to strictify the function that updates accumulator. Could you (or anyone) explain (in plain English, preferably:) the reason why 'seq' is the way it is. In the first place, why does it have the first

Re: [Haskell-cafe] [newbie] processing large logs

2006-05-14 Thread Udo Stenzel
Eugene Crosser wrote: Anyway, I understand that you used 'seq' in your example as a way to strictify the function that updates accumulator. Could you (or anyone) explain (in plain English, preferably:) the reason why 'seq' is the way it is. In the first place, why does it have the first

Re: [Haskell-cafe] CDouble type coercion

2006-05-14 Thread Sven Panne
Am Sonntag, 14. Mai 2006 09:30 schrieb SevenThunders: I am new to Haskell and found myself in a bind concerning the use of the C types, CDouble in particular. I extract a CDouble via it's pointer from a StorableArray. Since the array must interface with C the elements of the array must be

Re: [Haskell-cafe] CDouble type coercion

2006-05-14 Thread SevenThunders
Thanks that helps a bit. The realToFrac type coercion works, but ultimately it seems that printf won't play nice. Consider this simple haskell code module Test where import IO -- import Data.Array.Storable import Text.Printf import Foreign.C.Types (CInt, CDouble ) y :: CDouble y =

Re: [Haskell-cafe] CDouble type coercion

2006-05-14 Thread Robert Dockins
On Sunday 14 May 2006 03:00 pm, SevenThunders wrote: Thanks that helps a bit. The realToFrac type coercion works, but ultimately it seems that printf won't play nice. Consider this simple haskell code module Test where import IO -- import Data.Array.Storable import Text.Printf

[Haskell-cafe] Re: develop new Haskell shell?

2006-05-14 Thread Aaron Denney
On 2006-05-12, Jeremy Shaw [EMAIL PROTECTED] wrote: At Thu, 11 May 2006 23:05:14 +0100, Brian Hulley wrote: Of course the above could no doubt be improved but surely it is already far easier to understand and much more powerful than the idiosyncratic text based approach used in UNIX shells

[Haskell-cafe] Re: develop new Haskell shell?

2006-05-14 Thread Aaron Denney
On 2006-05-12, Max Vasin [EMAIL PROTECTED] wrote: Brian == Brian Hulley [EMAIL PROTECTED] writes: Brian Some other possibilities are: Brian 1) Every command returns a pair consisting of result and return Brian code IMHO the distinction between command's output (to stdout and stderr) and its

Re: [Haskell-cafe] CDouble type coercion

2006-05-14 Thread SevenThunders
The rabbit hole goes a bit deeper I'm afraid y :: CDouble y = 5.2 u :: Double u = realToFrac(y) test = do printf %14.7g u gives Compiling Test ( test.hs, interpreted ) test.hs:14:11: No instance for (PrintfType (t t1)) arising from use of `printf' at test.hs:14:11-16

Re: [Haskell-cafe] CDouble type coercion

2006-05-14 Thread Twan van Laarhoven
SevenThunders wrote: test.hs:14:11: No instance for (PrintfType (t t1)) arising from use of `printf' at test.hs:14:11-16 Probable fix: add an instance declaration for (PrintfType (t t1)) In the result of a 'do' expression: printf %14.7g u In the definition of `test':

[Haskell-cafe] dumb monad syntax question

2006-05-14 Thread mvanier
I've been reading Phil Wadler's monad papers from the early '90s, and it's been interesting to see how the monad concept evolved over the course of those years. But I haven't been able to track down the first use of the do notation for monads. Can anyone tell me where that came from? I'd

Re: [Haskell-cafe] dumb monad syntax question

2006-05-14 Thread Donald Bruce Stewart
mvanier: I've been reading Phil Wadler's monad papers from the early '90s, and it's been interesting to see how the monad concept evolved over the course of those years. But I haven't been able to track down the first use of the do notation for monads. Can anyone tell me where that came