Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)
To give a very casual explanation, both mains are of the form do this a bunch of times and return the results. Your first is do nothing and return the ()s, but importantly, it has to execute all those nothings. Your second is print hello a bunch and return the ()s. The list it wants to eventually return gets bigger and bigger as more prints happen, until poof! You should look at how replicateM works again, and hopefully it will make more sense with that in mind. On Sep 4, 2013 11:35 AM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: As an addendum to the recent discussion, can anyone explain why main crashes quickly with a stack overflow, whereas main' is happy to print Hi for ages (eventually crashing due to an out of memory condition)? bignum = 100 * 1000 * 1000 main = replicateM bignum (return ()) main' = replicateM bignum (putStrLn Hi) Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange IO sequence behaviour (Was: sequence causing stack overflow on pretty small lists)
Er, I seem to have misread and thought you were doing infinite replicateM, so that explanation doesn't completely address your question. That's what I get for reading on a phone! On Sep 4, 2013 4:11 PM, Joe Q headprogrammingc...@gmail.com wrote: To give a very casual explanation, both mains are of the form do this a bunch of times and return the results. Your first is do nothing and return the ()s, but importantly, it has to execute all those nothings. Your second is print hello a bunch and return the ()s. The list it wants to eventually return gets bigger and bigger as more prints happen, until poof! You should look at how replicateM works again, and hopefully it will make more sense with that in mind. On Sep 4, 2013 11:35 AM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: As an addendum to the recent discussion, can anyone explain why main crashes quickly with a stack overflow, whereas main' is happy to print Hi for ages (eventually crashing due to an out of memory condition)? bignum = 100 * 1000 * 1000 main = replicateM bignum (return ()) main' = replicateM bignum (putStrLn Hi) Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC and backwards compatibility
This is definitely an issue with the array package not setting the right minimum versions. You should email the maintainer. On Aug 19, 2013 11:05 AM, Ketil Malde ke...@malde.org wrote: I recently encountered the following problem: $ cabal install Resolving dependencies... Configuring array-0.4.0.1... Building array-0.4.0.1... Preprocessing library array-0.4.0.1... Data/Array/IArray.hs:1:14: Unsupported extension: Trustworthy cabal: Error: some packages failed to install: array-0.4.0.1 failed during the building phase. The exception was: ExitFailure 1 asmeval-0 depends on array-0.4.0.1 which failed to install. binary-0.7.1.0 depends on array-0.4.0.1 which failed to install. biocore-0.3.1 depends on array-0.4.0.1 which failed to install. biofasta-0.0.3 depends on array-0.4.0.1 which failed to install. biopsl-0.4 depends on array-0.4.0.1 which failed to install. biosff-0.3.3 depends on array-0.4.0.1 which failed to install. bytestring-0.10.2.0 depends on array-0.4.0.1 which failed to install. containers-0.5.2.1 depends on array-0.4.0.1 which failed to install. deepseq-1.3.0.1 depends on array-0.4.0.1 which failed to install. hashable-1.2.0.10 depends on array-0.4.0.1 which failed to install. stringable-0.1.1 depends on array-0.4.0.1 which failed to install. system-filepath-0.4.7 depends on array-0.4.0.1 which failed to install. text-0.11.3.1 depends on array-0.4.0.1 which failed to install. unordered-containers-0.2.3.1 depends on array-0.4.0.1 which failed to install. The installed GHC is 7.0.4, and yes, that's many major versions ago, but then again, it's only two years old, and from what I understand, it is shipped by some conservative Linux distributions. The problems here are that: a) the installation tries to install array, but current array requires the Trustworthy extension, which appeared in 7.2.1. Ideally, packages should try to be backwards compatible, e.g. by using conditional sections. b) the output isn't very helpful in tracking down the cause of this problem, it claims that all these packages depend on array-0.4.0.1, which is a lie. Somewhere, somehow, somethings depends on this (or at least a newer version), but I have no clue how to figure out which, except examining each of these packages and their dependencies manually. It is also possible that array shouldn't be upgraded like this, but then that needs to be made clear to cabal somehow, so that I don't spend ages trying to. Are there any solutions to this? Advice on how to proceed? -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question about Newtype op() function arguments.
The phantom parameter solves the same problem as scoped type variables. Granted, if you find yourself in that kind of polymorphic soup you have deeper problems... On Jun 7, 2013 2:53 PM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: On Fri, Jun 07, 2013 at 07:08:19AM -0700, David Banas wrote: op :: Newtype http://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/Control-Newtype.html#t:Newtype n o = (o - n) - n - oSource http://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/src/Control-Newtype.html#op This function serves two purposes: 1. Giving you the unpack of a newtype without you needing to remember the name. 2. Showing that the first parameter is *completely ignored* on the value level, meaning the only reason you pass in the constructor is to provide type information. Typeclasses sure are neat. As point #2, above, emphasizes, the only purpose for the first argument to the function (i.e. - the constructor (o - n)) is to specify the type of 'n'. However, being a *newtype*, 'n' can have only one constructor. So, why is it necessary to pass in the constructor to this function, when we're already passing in 'n'? I am puzzled by this too. What does op stand for? I hypothesis opposite in the sense of inverse, since as Roman points out op Constructor :: n - o is the inverse of Constructor :: o - n. But I admit I do not see how this provides value over unpack itself. Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] 9.3 - (2 * 4.5) = 0.3000000000000007
Welcome to IEEE floating point math! Wikipedia has a good article on the specification. If you want exact fractional numbers for your own purposes, there are a number of ways around the limits of floats. Rational will represent numbers internally as fractions, and still allow you to use the same syntax as above. The result will be 3 % 10, which you read as the fraction 3 / 10. If you also want irrational numbers, things get tricky. CReal will do it, but has some limitations. On Jan 16, 2013 8:26 AM, ivan dragolov i...@dragolov.net wrote: 9.3 - (2 * 4.5) = 0.3007 I expected 0.3 ? -- Иван Драголов dragolov.net GSM: 0888 63 19 46 GSM за SMS: 0878 82 83 93 facebook.com/ivan.dragolov twitter.com/dragolov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe