Hi, thanks for the reply..
Hi,
so let's say I want to generate a list of N random floats. The elegant
way of doing it would be to create an infinite lazy list of floats and
take the first N, but for N = 1,000,000 or more, this overflows the
stack. The reason is apparently that the take
Bryan O'Sullivan wrote:
Milos Hasan wrote:
so let's say I want to generate a list of N random floats. The elegant
way of doing it would be to create an infinite lazy list of floats and
take the first N, but for N = 1,000,000 or more, this overflows the
stack. The reason is apparently that
So, I did one more experiment, and the following overflows too:
import System.Random
import Data.List
randFloats :: [Float]
randFloats = randoms (mkStdGen 0)
main = print $ sum $ sort $ take 100 randFloats
Could it be that Data.List.sort is the culprit that uses O(n) stack
space here? If
Milos Hasan wrote:
Here's a minimal summing example that illustrates the difference. The
following works fine, since the elements are generated lazily and summed
on the fly, as expected:
randFloats :: [Float]
randFloats = randoms (mkStdGen 0)
main = do
let xs = take 100
On Sat, Mar 1, 2008 at 8:18 AM, Milos Hasan [EMAIL PROTECTED] wrote:
Here's a minimal summing example that illustrates the difference. The
following works fine, since the elements are generated lazily and summed
on the fly, as expected:
randFloats :: [Float]
randFloats = randoms
Milos Hasan wrote:
import System.Random
import Data.List
randFloats :: [Float]
randFloats = randoms (mkStdGen 0)
main = print $ sum $ sort $ take 100 randFloats
Could it be that Data.List.sort is the culprit that uses O(n) stack
space here? If so, is this avoidable?
sum is not
If I run the following program, it never prints done. If I
uncomment the commented line, it does.
import Prelude hiding (catch)
import Control.Exception
import System.Process
import System.IO
demo = do
putStrLn starting
(inp,out,err,pid) - runInteractiveCommand nonesuchcommand
putStrLn
The following is in ghci 6.8.2 with default options (e.g., default heap
and stack). G denotes the ghci prompt.
At some points ghci will use 500MB of memory. Be sure you have enough
physical memory.
G :m + Data.List System.Random
G let f n = take n randoms (mkStdGen 0)) :: [Float]
I define f
It is definitely the strictness analyzer biting you here. In ghci,
the behavior of these two programs is identical (stack overflow). As
kalman said, if you replate sum with foldl' (+) 0 in each of these
programs, the behavior is still identical (correct).
OK, I could replicate that
Hello,
I am trying to install a package on my Linux Ubuntu machine. It chokes
build-depends: base, directory because directory dependency is
unresolvable. Do I have to specify extra-libs so that correct library
space is searched? Actually I tried this and it didn't help. ??
Regards, Vasya
Well, it is simply
coerce :: a - b
coerce _ = undefined
so coerce is simply empty function. But still, it is possible to write a
function of type (a-b).
Well, possibly I didn't write anything particularly new, but please excuse
me for I'm still in
sort of a shock after I've discovered it.
Yet
On Mar 1, 2008, at 13:39 , Evan Martin wrote:
If I run the following program, it never prints done. If I
uncomment the commented line, it does.
The exception it's getting is a UNIX signal (SIGPIPE), whose default
action if not caught is to silently kill the process. Establish a
signal
On 2 mar 2008, at 01.21, Krzysztof Skrzętnicki wrote:
Well, it is simply
coerce :: a - b
coerce _ = undefined
so coerce is simply empty function. But still, it is possible to
write a function of type (a-b).
Well, possibly I didn't write anything particularly new, but please
excuse me
2008/3/1 Galchin Vasili [EMAIL PROTECTED]:
I am trying to install a package on my Linux Ubuntu machine. It chokes
build-depends: base, directory because directory dependency is
unresolvable. Do I have to specify extra-libs so that correct library
space is searched? Actually I tried this
2008/3/1, Milos Hasan [EMAIL PROTECTED]:
OK, thanks, this is an important point. So maybe I should have done this?
main = print $ foldl1' (+) $! take 100 randFloats
My intuition tells me that the $! (and `seq`) just reduces one level (to
WHNF?). If so, is there a way to force complete
OK, you convinced me that sort is not the problem. After all, last (f
100) overflows too, and last is a very innocent function.
I don't know how you found the size (or structure) of the thunks (I'm
not aware of a ghci functionality that can tell me that), could you let
me know?
Anyway,
exactly .. I have version 6.6.1 ... question is how do I get the Unbuntu
package for version 6.8?
V.
On Sat, Mar 1, 2008 at 8:02 PM, Adam Langley [EMAIL PROTECTED] wrote:
2008/3/1 Galchin Vasili [EMAIL PROTECTED]:
I am trying to install a package on my Linux Ubuntu machine. It
chokes
A big thanks to you all for the discussion. I have determined that a
monad is actually not the best representation of a circular list of
functions. I was able to implement it without any special syntax or
unusual typing. For the curious:
--
18 matches
Mail list logo