Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-12 Thread Bryan O'Sullivan
Ketil Malde wrote: I'd really like to have errors on overflow, at least as an option, even if it is costly in terms of performance. Is there a Trac ticket or something for this? Not that I know of. I filed a Trac ticket against ByteString's readInt function before I noticed that read has th

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-12 Thread Ketil Malde
On Wed, 2007-07-11 at 10:55 -0700, Bryan O'Sullivan wrote: > In a similar vein, I was initially perplexed when I > found that an expression like this produces garbage instead of an error: > >read "111" :: Int > > I have not seen a lot of interest expressed in

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Brandon S. Allbery KF8NH
On Jul 11, 2007, at 19:11 , Thomas Conway wrote: Is there a compelling reason (hysterical raisins is not a compelling reason) why Data.*.{length,size,take,drop,etc} use Int and not Num n => or similar? Efficiency, but many of them have generic equivalents (e.g. genericLength, genericDr

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Thomas Conway
On 7/12/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: Indeed. I beleive that Int should be removed from the Prelude. metoo. Actually, one of the really annoying things that I am finding in my code which is a mixture of ByteString, Word16, Word32 and Word64, is that all the standard libraries u

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Stefan O'Rear
On Wed, Jul 11, 2007 at 08:16:50PM +0100, Andrew Coppin wrote: > Bryan O'Sullivan wrote: >> Richard Kelsall wrote: >> >>> I guess there must be a switch to make it produce a nice >>> error message rather than overflowing without warning. >> >> Actually, there isn't. > > I for one sometimes wish the

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Andrew Coppin
Bryan O'Sullivan wrote: Richard Kelsall wrote: I guess there must be a switch to make it produce a nice error message rather than overflowing without warning. Actually, there isn't. I for one sometimes wish there was... Of course, sometimes you purposely write code which you know is going

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Bryan O'Sullivan
Albert Y. C. Lai wrote: I'm just being picky here: where the underlying machine's behaviour is 2's complement binary, it (Int, +, *) is actually a tidy, well-behaved mathematical ring, isomorphic to Z / 2^n Z. Yes, naturally it wasn't until a few moments after I had sent the message that I n

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Albert Y. C. Lai
Bryan O'Sullivan wrote: Int is a bit of an odd fish that way; it's a window onto the underlying machine's behaviour, not a tidy, well-behaved mathematical ring. I'm just being picky here: where the underlying machine's behaviour is 2's complement binary, it (Int, +, *) is actually a tidy, wel

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Stefan O'Rear
On Wed, Jul 11, 2007 at 10:55:28AM -0700, Bryan O'Sullivan wrote: > Richard Kelsall wrote: >> It seems to randomly claim to have successfully created huge sizes >> of array. > > This may be outside of Haskell's control, as you're not actually touching > the memory you allocate. I wouldn't be surp

Re: [Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Bryan O'Sullivan
Richard Kelsall wrote: main = do n <- getArgs >>= readIO . head :: IO Int a <- newArray (1,n) True :: IO (IOUArray Int Bool) printf "Created array 1 .. %8d \n" (n::Int) :: IO () It appears to work up to quite large numbers, but then gets strange. When I give it an array size of 1,00

[Haskell-cafe] Strange results when trying to create large Bool arrays.

2007-07-11 Thread Richard Kelsall
My first ever Haskell program just creates an array in memory. I wanted to try creating really big arrays. import Data.Array.IO import System import Text.Printf main = do n <- getArgs >>= readIO . head :: IO Int a <- newArray (1,n) True :: IO (IOUArray Int Bool) printf "Created array