On Sat, Oct 10, 2009 at 11:11:24PM +0200, Daniel Fischer wrote:
To: haskell-cafe@haskell.org
From: Daniel Fischer daniel.is.fisc...@web.de
Date: Sat, 10 Oct 2009 23:11:24 +0200
Subject: Re: [Haskell-cafe] How do I get this done in constant mem?
Am Samstag 10 Oktober 2009 22:14:38 schrieb
I don't know if this counts but how about
import Control.Applicative
import Control.Monad
import Random
import Data.List
main'' i j = replicateM j $ maximum' $ (replicateM i . randomRIO $ (0,10^9))
maximum' = foldl1' max
t = main'' (10^4) 5
2009/10/9 mf-hcafe-15c311...@etc-network.de:
Hi
Yes, you should not do this in IO. That requires the entire
computation to finish before the result can be used.
Not really the entire computation though... whnf, no?
main = do
let thunks :: IO [Int]
thunks = (sequence . replicate (10^6) $ (randomRIO (0,10^9)))
putStrLn . show . head =
also, looking at the following, it does seem to me that it is sequence
that is too strict, and not IO that is to blame, as the Maybe monad
has the same behavior:
t5IO, t6IO :: IO Int
t5Maybe, t6Maybe :: Maybe Int
t5 = return . head = sequence [return 1, undefined]
t6 = return . head = return
On Fri, Oct 09, 2009 at 05:48:15PM -0600, Luke Palmer wrote:
To: mf-hcafe-15c311...@etc-network.de
Cc:
From: Luke Palmer lrpal...@gmail.com
Date: Fri, 9 Oct 2009 17:48:15 -0600
Subject: Re: [Haskell-cafe] How do I get this done in constant mem?
On Fri, Oct 9, 2009 at 2:05 PM, mf-hcafe
On Sat, Oct 10, 2009 at 09:33:52AM -0700, Thomas Hartman wrote:
To: Luke Palmer lrpal...@gmail.com
Cc: mf-hcafe-15c311...@etc-network.de, haskell-cafe@haskell.org
From: Thomas Hartman tphya...@gmail.com
Date: Sat, 10 Oct 2009 09:33:52 -0700
Subject: Re: [Haskell-cafe] How do I get this done
: Sat, 10 Oct 2009 09:33:52 -0700
Subject: Re: [Haskell-cafe] How do I get this done in constant mem?
Yes, you should not do this in IO. That requires the entire
computation to finish before the result can be used.
Not really the entire computation though... whnf, no?
In that example
Hi all,
I think there is something about my use of the IO monad that bites me,
but I am bored of staring at the code, so here you g. The code goes
through a list of records and collects the maximum in each record
position.
-- test.hs
import Random
import System.Environment (getArgs)
import
On Fri, Oct 9, 2009 at 2:05 PM, mf-hcafe-15c311...@etc-network.de wrote:
Hi all,
I think there is something about my use of the IO monad that bites me,
but I am bored of staring at the code, so here you g. The code goes
through a list of records and collects the maximum in each record